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