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 StoriesStoryViews struct {
Views []StoryViews
Users []UserClass
}
const StoriesStoryViewsTypeID = 0xde9eed1d
var (
_ bin .Encoder = &StoriesStoryViews {}
_ bin .Decoder = &StoriesStoryViews {}
_ bin .BareEncoder = &StoriesStoryViews {}
_ bin .BareDecoder = &StoriesStoryViews {}
)
func (s *StoriesStoryViews ) Zero () bool {
if s == nil {
return true
}
if !(s .Views == nil ) {
return false
}
if !(s .Users == nil ) {
return false
}
return true
}
func (s *StoriesStoryViews ) String () string {
if s == nil {
return "StoriesStoryViews(nil)"
}
type Alias StoriesStoryViews
return fmt .Sprintf ("StoriesStoryViews%+v" , Alias (*s ))
}
func (s *StoriesStoryViews ) FillFrom (from interface {
GetViews () (value []StoryViews )
GetUsers () (value []UserClass )
}) {
s .Views = from .GetViews ()
s .Users = from .GetUsers ()
}
func (*StoriesStoryViews ) TypeID () uint32 {
return StoriesStoryViewsTypeID
}
func (*StoriesStoryViews ) TypeName () string {
return "stories.storyViews"
}
func (s *StoriesStoryViews ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "stories.storyViews" ,
ID : StoriesStoryViewsTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Views" ,
SchemaName : "views" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (s *StoriesStoryViews ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.storyViews#de9eed1d as nil" )
}
b .PutID (StoriesStoryViewsTypeID )
return s .EncodeBare (b )
}
func (s *StoriesStoryViews ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode stories.storyViews#de9eed1d as nil" )
}
b .PutVectorHeader (len (s .Views ))
for idx , v := range s .Views {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.storyViews#de9eed1d: field views 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.storyViews#de9eed1d: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode stories.storyViews#de9eed1d: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *StoriesStoryViews ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.storyViews#de9eed1d to nil" )
}
if err := b .ConsumeID (StoriesStoryViewsTypeID ); err != nil {
return fmt .Errorf ("unable to decode stories.storyViews#de9eed1d: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StoriesStoryViews ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode stories.storyViews#de9eed1d to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.storyViews#de9eed1d: field views: %w" , err )
}
if headerLen > 0 {
s .Views = make ([]StoryViews , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StoryViews
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode stories.storyViews#de9eed1d: field views: %w" , err )
}
s .Views = append (s .Views , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode stories.storyViews#de9eed1d: 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.storyViews#de9eed1d: field users: %w" , err )
}
s .Users = append (s .Users , value )
}
}
return nil
}
func (s *StoriesStoryViews ) GetViews () (value []StoryViews ) {
if s == nil {
return
}
return s .Views
}
func (s *StoriesStoryViews ) GetUsers () (value []UserClass ) {
if s == nil {
return
}
return s .Users
}
func (s *StoriesStoryViews ) 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 .