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