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 AccountSavedRingtonesNotModified struct {
}
const AccountSavedRingtonesNotModifiedTypeID = 0xfbf6e8b1
func (s AccountSavedRingtonesNotModified ) construct () AccountSavedRingtonesClass { return &s }
var (
_ bin .Encoder = &AccountSavedRingtonesNotModified {}
_ bin .Decoder = &AccountSavedRingtonesNotModified {}
_ bin .BareEncoder = &AccountSavedRingtonesNotModified {}
_ bin .BareDecoder = &AccountSavedRingtonesNotModified {}
_ AccountSavedRingtonesClass = &AccountSavedRingtonesNotModified {}
)
func (s *AccountSavedRingtonesNotModified ) Zero () bool {
if s == nil {
return true
}
return true
}
func (s *AccountSavedRingtonesNotModified ) String () string {
if s == nil {
return "AccountSavedRingtonesNotModified(nil)"
}
type Alias AccountSavedRingtonesNotModified
return fmt .Sprintf ("AccountSavedRingtonesNotModified%+v" , Alias (*s ))
}
func (*AccountSavedRingtonesNotModified ) TypeID () uint32 {
return AccountSavedRingtonesNotModifiedTypeID
}
func (*AccountSavedRingtonesNotModified ) TypeName () string {
return "account.savedRingtonesNotModified"
}
func (s *AccountSavedRingtonesNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.savedRingtonesNotModified" ,
ID : AccountSavedRingtonesNotModifiedTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (s *AccountSavedRingtonesNotModified ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.savedRingtonesNotModified#fbf6e8b1 as nil" )
}
b .PutID (AccountSavedRingtonesNotModifiedTypeID )
return s .EncodeBare (b )
}
func (s *AccountSavedRingtonesNotModified ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.savedRingtonesNotModified#fbf6e8b1 as nil" )
}
return nil
}
func (s *AccountSavedRingtonesNotModified ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.savedRingtonesNotModified#fbf6e8b1 to nil" )
}
if err := b .ConsumeID (AccountSavedRingtonesNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.savedRingtonesNotModified#fbf6e8b1: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AccountSavedRingtonesNotModified ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.savedRingtonesNotModified#fbf6e8b1 to nil" )
}
return nil
}
type AccountSavedRingtones struct {
Hash int64
Ringtones []DocumentClass
}
const AccountSavedRingtonesTypeID = 0xc1e92cc5
func (s AccountSavedRingtones ) construct () AccountSavedRingtonesClass { return &s }
var (
_ bin .Encoder = &AccountSavedRingtones {}
_ bin .Decoder = &AccountSavedRingtones {}
_ bin .BareEncoder = &AccountSavedRingtones {}
_ bin .BareDecoder = &AccountSavedRingtones {}
_ AccountSavedRingtonesClass = &AccountSavedRingtones {}
)
func (s *AccountSavedRingtones ) Zero () bool {
if s == nil {
return true
}
if !(s .Hash == 0 ) {
return false
}
if !(s .Ringtones == nil ) {
return false
}
return true
}
func (s *AccountSavedRingtones ) String () string {
if s == nil {
return "AccountSavedRingtones(nil)"
}
type Alias AccountSavedRingtones
return fmt .Sprintf ("AccountSavedRingtones%+v" , Alias (*s ))
}
func (s *AccountSavedRingtones ) FillFrom (from interface {
GetHash () (value int64 )
GetRingtones () (value []DocumentClass )
}) {
s .Hash = from .GetHash ()
s .Ringtones = from .GetRingtones ()
}
func (*AccountSavedRingtones ) TypeID () uint32 {
return AccountSavedRingtonesTypeID
}
func (*AccountSavedRingtones ) TypeName () string {
return "account.savedRingtones"
}
func (s *AccountSavedRingtones ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.savedRingtones" ,
ID : AccountSavedRingtonesTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Ringtones" ,
SchemaName : "ringtones" ,
},
}
return typ
}
func (s *AccountSavedRingtones ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.savedRingtones#c1e92cc5 as nil" )
}
b .PutID (AccountSavedRingtonesTypeID )
return s .EncodeBare (b )
}
func (s *AccountSavedRingtones ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.savedRingtones#c1e92cc5 as nil" )
}
b .PutLong (s .Hash )
b .PutVectorHeader (len (s .Ringtones ))
for idx , v := range s .Ringtones {
if v == nil {
return fmt .Errorf ("unable to encode account.savedRingtones#c1e92cc5: field ringtones element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.savedRingtones#c1e92cc5: field ringtones element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *AccountSavedRingtones ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.savedRingtones#c1e92cc5 to nil" )
}
if err := b .ConsumeID (AccountSavedRingtonesTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.savedRingtones#c1e92cc5: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AccountSavedRingtones ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.savedRingtones#c1e92cc5 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode account.savedRingtones#c1e92cc5: field hash: %w" , err )
}
s .Hash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.savedRingtones#c1e92cc5: field ringtones: %w" , err )
}
if headerLen > 0 {
s .Ringtones = make ([]DocumentClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode account.savedRingtones#c1e92cc5: field ringtones: %w" , err )
}
s .Ringtones = append (s .Ringtones , value )
}
}
return nil
}
func (s *AccountSavedRingtones ) GetHash () (value int64 ) {
if s == nil {
return
}
return s .Hash
}
func (s *AccountSavedRingtones ) GetRingtones () (value []DocumentClass ) {
if s == nil {
return
}
return s .Ringtones
}
func (s *AccountSavedRingtones ) MapRingtones () (value DocumentClassArray ) {
return DocumentClassArray (s .Ringtones )
}
const AccountSavedRingtonesClassName = "account.SavedRingtones"
type AccountSavedRingtonesClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () AccountSavedRingtonesClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*AccountSavedRingtones , bool )
}
func (s *AccountSavedRingtonesNotModified ) AsModified () (*AccountSavedRingtones , bool ) {
return nil , false
}
func (s *AccountSavedRingtones ) AsModified () (*AccountSavedRingtones , bool ) {
return s , true
}
func DecodeAccountSavedRingtones (buf *bin .Buffer ) (AccountSavedRingtonesClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case AccountSavedRingtonesNotModifiedTypeID :
v := AccountSavedRingtonesNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountSavedRingtonesClass: %w" , err )
}
return &v , nil
case AccountSavedRingtonesTypeID :
v := AccountSavedRingtones {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AccountSavedRingtonesClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode AccountSavedRingtonesClass: %w" , bin .NewUnexpectedID (id ))
}
}
type AccountSavedRingtonesBox struct {
SavedRingtones AccountSavedRingtonesClass
}
func (b *AccountSavedRingtonesBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode AccountSavedRingtonesBox to nil" )
}
v , err := DecodeAccountSavedRingtones (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .SavedRingtones = v
return nil
}
func (b *AccountSavedRingtonesBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .SavedRingtones == nil {
return fmt .Errorf ("unable to encode AccountSavedRingtonesClass as nil" )
}
return b .SavedRingtones .Encode (buf )
}
The pages are generated with Golds v0.6.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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .