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