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 StoriesStories struct {
Count int
Stories []StoryItemClass
Chats []ChatClass
Users []UserClass
}
const StoriesStoriesTypeID = 0x5dd8c3c8
var (
_ bin .Encoder = &StoriesStories {}
_ bin .Decoder = &StoriesStories {}
_ bin .BareEncoder = &StoriesStories {}
_ bin .BareDecoder = &StoriesStories {}
)
func (s *StoriesStories ) Zero () bool {
if s == nil {
return true
}
if !(s .Count == 0 ) {
return false
}
if !(s .Stories == nil ) {
return false
}
if !(s .Chats == nil ) {
return false
}
if !(s .Users == nil ) {
return false
}
return true
}
func (s *StoriesStories ) String () string {
if s == nil {
return "StoriesStories(nil)"
}
type Alias StoriesStories
return fmt .Sprintf ("StoriesStories%+v" , Alias (*s ))
}
func (s *StoriesStories ) FillFrom (from interface {
GetCount () (value int )
GetStories () (value []StoryItemClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
s .Count = from .GetCount ()
s .Stories = from .GetStories ()
s .Chats = from .GetChats ()
s .Users = from .GetUsers ()
}
func (*StoriesStories ) TypeID () uint32 {
return StoriesStoriesTypeID
}
func (*StoriesStories ) TypeName () string {
return "stories.stories"
}
func (s *StoriesStories ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.stories" ,
ID : StoriesStoriesTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Stories" ,
SchemaName : "stories" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (s *StoriesStories ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.stories#5dd8c3c8 as nil" )
}
b .PutID (StoriesStoriesTypeID )
return s .EncodeBare (b )
}
func (s *StoriesStories ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.stories#5dd8c3c8 as nil" )
}
b .PutInt (s .Count )
b .PutVectorHeader (len (s .Stories ))
for idx , v := range s .Stories {
if v == nil {
return fmt .Errorf ("unable to encode stories.stories#5dd8c3c8: field stories element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.stories#5dd8c3c8: field stories element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Chats ))
for idx , v := range s .Chats {
if v == nil {
return fmt .Errorf ("unable to encode stories.stories#5dd8c3c8: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.stories#5dd8c3c8: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Users ))
for idx , v := range s .Users {
if v == nil {
return fmt .Errorf ("unable to encode stories.stories#5dd8c3c8: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.stories#5dd8c3c8: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *StoriesStories ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.stories#5dd8c3c8 to nil" )
}
if err := b .ConsumeID (StoriesStoriesTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoriesStories ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.stories#5dd8c3c8 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: field count: %w" , err )
}
s .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: field stories: %w" , err )
}
if headerLen > 0 {
s .Stories = make ([]StoryItemClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeStoryItem (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: field stories: %w" , err )
}
s .Stories = append (s .Stories , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: field chats: %w" , err )
}
if headerLen > 0 {
s .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: field chats: %w" , err )
}
s .Chats = append (s .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: field users: %w" , err )
}
if headerLen > 0 {
s .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode stories.stories#5dd8c3c8: field users: %w" , err )
}
s .Users = append (s .Users , value )
}
}
return nil
}
func (s *StoriesStories ) GetCount () (value int ) {
if s == nil {
return
}
return s .Count
}
func (s *StoriesStories ) GetStories () (value []StoryItemClass ) {
if s == nil {
return
}
return s .Stories
}
func (s *StoriesStories ) GetChats () (value []ChatClass ) {
if s == nil {
return
}
return s .Chats
}
func (s *StoriesStories ) GetUsers () (value []UserClass ) {
if s == nil {
return
}
return s .Users
}
func (s *StoriesStories ) MapStories () (value StoryItemClassArray ) {
return StoryItemClassArray (s .Stories )
}
func (s *StoriesStories ) MapChats () (value ChatClassArray ) {
return ChatClassArray (s .Chats )
}
func (s *StoriesStories ) MapUsers () (value UserClassArray ) {
return UserClassArray (s .Users )
}
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 .