package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type TonConnectManifest struct {
Flags bin .Fields
URL string
Name string
Icon WebDocumentClass
}
const TonConnectManifestTypeID = 0x12229264
var (
_ bin .Encoder = &TonConnectManifest {}
_ bin .Decoder = &TonConnectManifest {}
_ bin .BareEncoder = &TonConnectManifest {}
_ bin .BareDecoder = &TonConnectManifest {}
)
func (t *TonConnectManifest ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .URL == "" ) {
return false
}
if !(t .Name == "" ) {
return false
}
if !(t .Icon == nil ) {
return false
}
return true
}
func (t *TonConnectManifest ) String () string {
if t == nil {
return "TonConnectManifest(nil)"
}
type Alias TonConnectManifest
return fmt .Sprintf ("TonConnectManifest%+v" , Alias (*t ))
}
func (t *TonConnectManifest ) FillFrom (from interface {
GetURL () (value string )
GetName () (value string )
GetIcon () (value WebDocumentClass , ok bool )
}) {
t .URL = from .GetURL ()
t .Name = from .GetName ()
if val , ok := from .GetIcon (); ok {
t .Icon = val
}
}
func (*TonConnectManifest ) TypeID () uint32 {
return TonConnectManifestTypeID
}
func (*TonConnectManifest ) TypeName () string {
return "tonConnectManifest"
}
func (t *TonConnectManifest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "tonConnectManifest" ,
ID : TonConnectManifestTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "URL" ,
SchemaName : "url" ,
},
{
Name : "Name" ,
SchemaName : "name" ,
},
{
Name : "Icon" ,
SchemaName : "icon" ,
Null : !t .Flags .Has (0 ),
},
}
return typ
}
func (t *TonConnectManifest ) SetFlags () {
if !(t .Icon == nil ) {
t .Flags .Set (0 )
}
}
func (t *TonConnectManifest ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode tonConnectManifest#12229264 as nil" )
}
b .PutID (TonConnectManifestTypeID )
return t .EncodeBare (b )
}
func (t *TonConnectManifest ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode tonConnectManifest#12229264 as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode tonConnectManifest#12229264: field flags: %w" , err )
}
b .PutString (t .URL )
b .PutString (t .Name )
if t .Flags .Has (0 ) {
if t .Icon == nil {
return fmt .Errorf ("unable to encode tonConnectManifest#12229264: field icon is nil" )
}
if err := t .Icon .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode tonConnectManifest#12229264: field icon: %w" , err )
}
}
return nil
}
func (t *TonConnectManifest ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode tonConnectManifest#12229264 to nil" )
}
if err := b .ConsumeID (TonConnectManifestTypeID ); err != nil {
return fmt .Errorf ("unable to decode tonConnectManifest#12229264: %w" , err )
}
return t .DecodeBare (b )
}
func (t *TonConnectManifest ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode tonConnectManifest#12229264 to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode tonConnectManifest#12229264: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectManifest#12229264: field url: %w" , err )
}
t .URL = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode tonConnectManifest#12229264: field name: %w" , err )
}
t .Name = value
}
if t .Flags .Has (0 ) {
value , err := DecodeWebDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode tonConnectManifest#12229264: field icon: %w" , err )
}
t .Icon = value
}
return nil
}
func (t *TonConnectManifest ) GetURL () (value string ) {
if t == nil {
return
}
return t .URL
}
func (t *TonConnectManifest ) GetName () (value string ) {
if t == nil {
return
}
return t .Name
}
func (t *TonConnectManifest ) SetIcon (value WebDocumentClass ) {
t .Flags .Set (0 )
t .Icon = value
}
func (t *TonConnectManifest ) GetIcon () (value WebDocumentClass , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (0 ) {
return value , false
}
return t .Icon , true
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .