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 StoriesAlbumsNotModified struct {
}
const StoriesAlbumsNotModifiedTypeID = 0x564edaeb
func (a StoriesAlbumsNotModified ) construct () StoriesAlbumsClass { return &a }
var (
_ bin .Encoder = &StoriesAlbumsNotModified {}
_ bin .Decoder = &StoriesAlbumsNotModified {}
_ bin .BareEncoder = &StoriesAlbumsNotModified {}
_ bin .BareDecoder = &StoriesAlbumsNotModified {}
_ StoriesAlbumsClass = &StoriesAlbumsNotModified {}
)
func (a *StoriesAlbumsNotModified ) Zero () bool {
if a == nil {
return true
}
return true
}
func (a *StoriesAlbumsNotModified ) String () string {
if a == nil {
return "StoriesAlbumsNotModified(nil)"
}
type Alias StoriesAlbumsNotModified
return fmt .Sprintf ("StoriesAlbumsNotModified%+v" , Alias (*a ))
}
func (*StoriesAlbumsNotModified ) TypeID () uint32 {
return StoriesAlbumsNotModifiedTypeID
}
func (*StoriesAlbumsNotModified ) TypeName () string {
return "stories.albumsNotModified"
}
func (a *StoriesAlbumsNotModified ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.albumsNotModified" ,
ID : StoriesAlbumsNotModifiedTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (a *StoriesAlbumsNotModified ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.albumsNotModified#564edaeb as nil" )
}
b .PutID (StoriesAlbumsNotModifiedTypeID )
return a .EncodeBare (b )
}
func (a *StoriesAlbumsNotModified ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.albumsNotModified#564edaeb as nil" )
}
return nil
}
func (a *StoriesAlbumsNotModified ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.albumsNotModified#564edaeb to nil" )
}
if err := b .ConsumeID (StoriesAlbumsNotModifiedTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.albumsNotModified#564edaeb: %w" , err )
}
return a .DecodeBare (b )
}
func (a *StoriesAlbumsNotModified ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.albumsNotModified#564edaeb to nil" )
}
return nil
}
type StoriesAlbums struct {
Hash int64
Albums []StoryAlbum
}
const StoriesAlbumsTypeID = 0xc3987a3a
func (a StoriesAlbums ) construct () StoriesAlbumsClass { return &a }
var (
_ bin .Encoder = &StoriesAlbums {}
_ bin .Decoder = &StoriesAlbums {}
_ bin .BareEncoder = &StoriesAlbums {}
_ bin .BareDecoder = &StoriesAlbums {}
_ StoriesAlbumsClass = &StoriesAlbums {}
)
func (a *StoriesAlbums ) Zero () bool {
if a == nil {
return true
}
if !(a .Hash == 0 ) {
return false
}
if !(a .Albums == nil ) {
return false
}
return true
}
func (a *StoriesAlbums ) String () string {
if a == nil {
return "StoriesAlbums(nil)"
}
type Alias StoriesAlbums
return fmt .Sprintf ("StoriesAlbums%+v" , Alias (*a ))
}
func (a *StoriesAlbums ) FillFrom (from interface {
GetHash () (value int64 )
GetAlbums () (value []StoryAlbum )
}) {
a .Hash = from .GetHash ()
a .Albums = from .GetAlbums ()
}
func (*StoriesAlbums ) TypeID () uint32 {
return StoriesAlbumsTypeID
}
func (*StoriesAlbums ) TypeName () string {
return "stories.albums"
}
func (a *StoriesAlbums ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.albums" ,
ID : StoriesAlbumsTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Hash" ,
SchemaName : "hash" ,
},
{
Name : "Albums" ,
SchemaName : "albums" ,
},
}
return typ
}
func (a *StoriesAlbums ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.albums#c3987a3a as nil" )
}
b .PutID (StoriesAlbumsTypeID )
return a .EncodeBare (b )
}
func (a *StoriesAlbums ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode stories.albums#c3987a3a as nil" )
}
b .PutLong (a .Hash )
b .PutVectorHeader (len (a .Albums ))
for idx , v := range a .Albums {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.albums#c3987a3a: field albums element with index %d: %w" , idx , err )
}
}
return nil
}
func (a *StoriesAlbums ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.albums#c3987a3a to nil" )
}
if err := b .ConsumeID (StoriesAlbumsTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.albums#c3987a3a: %w" , err )
}
return a .DecodeBare (b )
}
func (a *StoriesAlbums ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode stories.albums#c3987a3a to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode stories.albums#c3987a3a: field hash: %w" , err )
}
a .Hash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.albums#c3987a3a: field albums: %w" , err )
}
if headerLen > 0 {
a .Albums = make ([]StoryAlbum , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StoryAlbum
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.albums#c3987a3a: field albums: %w" , err )
}
a .Albums = append (a .Albums , value )
}
}
return nil
}
func (a *StoriesAlbums ) GetHash () (value int64 ) {
if a == nil {
return
}
return a .Hash
}
func (a *StoriesAlbums ) GetAlbums () (value []StoryAlbum ) {
if a == nil {
return
}
return a .Albums
}
const StoriesAlbumsClassName = "stories.Albums"
type StoriesAlbumsClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StoriesAlbumsClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsModified () (*StoriesAlbums , bool )
}
func (a *StoriesAlbumsNotModified ) AsModified () (*StoriesAlbums , bool ) {
return nil , false
}
func (a *StoriesAlbums ) AsModified () (*StoriesAlbums , bool ) {
return a , true
}
func DecodeStoriesAlbums (buf *bin .Buffer ) (StoriesAlbumsClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StoriesAlbumsNotModifiedTypeID :
v := StoriesAlbumsNotModified {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoriesAlbumsClass: %w" , err )
}
return &v , nil
case StoriesAlbumsTypeID :
v := StoriesAlbums {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StoriesAlbumsClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode StoriesAlbumsClass: %w" , bin .NewUnexpectedID (id ))
}
}
type StoriesAlbumsBox struct {
Albums StoriesAlbumsClass
}
func (b *StoriesAlbumsBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode StoriesAlbumsBox to nil" )
}
v , err := DecodeStoriesAlbums (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Albums = v
return nil
}
func (b *StoriesAlbumsBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Albums == nil {
return fmt .Errorf ("unable to encode StoriesAlbumsClass as nil" )
}
return b .Albums .Encode (buf )
}
The pages are generated with Golds v0.8.4 . (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 .