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 ContactsBlocked struct {
Blocked []PeerBlocked
Chats []ChatClass
Users []UserClass
}
const ContactsBlockedTypeID = 0xade1591
func (b ContactsBlocked ) construct () ContactsBlockedClass { return &b }
var (
_ bin .Encoder = &ContactsBlocked {}
_ bin .Decoder = &ContactsBlocked {}
_ bin .BareEncoder = &ContactsBlocked {}
_ bin .BareDecoder = &ContactsBlocked {}
_ ContactsBlockedClass = &ContactsBlocked {}
)
func (b *ContactsBlocked ) Zero () bool {
if b == nil {
return true
}
if !(b .Blocked == nil ) {
return false
}
if !(b .Chats == nil ) {
return false
}
if !(b .Users == nil ) {
return false
}
return true
}
func (b *ContactsBlocked ) String () string {
if b == nil {
return "ContactsBlocked(nil)"
}
type Alias ContactsBlocked
return fmt .Sprintf ("ContactsBlocked%+v" , Alias (*b ))
}
func (b *ContactsBlocked ) FillFrom (from interface {
GetBlocked () (value []PeerBlocked )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
b .Blocked = from .GetBlocked ()
b .Chats = from .GetChats ()
b .Users = from .GetUsers ()
}
func (*ContactsBlocked ) TypeID () uint32 {
return ContactsBlockedTypeID
}
func (*ContactsBlocked ) TypeName () string {
return "contacts.blocked"
}
func (b *ContactsBlocked ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.blocked" ,
ID : ContactsBlockedTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Blocked" ,
SchemaName : "blocked" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (b *ContactsBlocked ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode contacts.blocked#ade1591 as nil" )
}
buf .PutID (ContactsBlockedTypeID )
return b .EncodeBare (buf )
}
func (b *ContactsBlocked ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode contacts.blocked#ade1591 as nil" )
}
buf .PutVectorHeader (len (b .Blocked ))
for idx , v := range b .Blocked {
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.blocked#ade1591: field blocked element with index %d: %w" , idx , err )
}
}
buf .PutVectorHeader (len (b .Chats ))
for idx , v := range b .Chats {
if v == nil {
return fmt .Errorf ("unable to encode contacts.blocked#ade1591: field chats element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.blocked#ade1591: field chats element with index %d: %w" , idx , err )
}
}
buf .PutVectorHeader (len (b .Users ))
for idx , v := range b .Users {
if v == nil {
return fmt .Errorf ("unable to encode contacts.blocked#ade1591: field users element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.blocked#ade1591: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (b *ContactsBlocked ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode contacts.blocked#ade1591 to nil" )
}
if err := buf .ConsumeID (ContactsBlockedTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.blocked#ade1591: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *ContactsBlocked ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode contacts.blocked#ade1591 to nil" )
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.blocked#ade1591: field blocked: %w" , err )
}
if headerLen > 0 {
b .Blocked = make ([]PeerBlocked , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value PeerBlocked
if err := value .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode contacts.blocked#ade1591: field blocked: %w" , err )
}
b .Blocked = append (b .Blocked , value )
}
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.blocked#ade1591: field chats: %w" , err )
}
if headerLen > 0 {
b .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (buf )
if err != nil {
return fmt .Errorf ("unable to decode contacts.blocked#ade1591: field chats: %w" , err )
}
b .Chats = append (b .Chats , value )
}
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.blocked#ade1591: field users: %w" , err )
}
if headerLen > 0 {
b .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (buf )
if err != nil {
return fmt .Errorf ("unable to decode contacts.blocked#ade1591: field users: %w" , err )
}
b .Users = append (b .Users , value )
}
}
return nil
}
func (b *ContactsBlocked ) GetBlocked () (value []PeerBlocked ) {
if b == nil {
return
}
return b .Blocked
}
func (b *ContactsBlocked ) GetChats () (value []ChatClass ) {
if b == nil {
return
}
return b .Chats
}
func (b *ContactsBlocked ) GetUsers () (value []UserClass ) {
if b == nil {
return
}
return b .Users
}
func (b *ContactsBlocked ) MapChats () (value ChatClassArray ) {
return ChatClassArray (b .Chats )
}
func (b *ContactsBlocked ) MapUsers () (value UserClassArray ) {
return UserClassArray (b .Users )
}
type ContactsBlockedSlice struct {
Count int
Blocked []PeerBlocked
Chats []ChatClass
Users []UserClass
}
const ContactsBlockedSliceTypeID = 0xe1664194
func (b ContactsBlockedSlice ) construct () ContactsBlockedClass { return &b }
var (
_ bin .Encoder = &ContactsBlockedSlice {}
_ bin .Decoder = &ContactsBlockedSlice {}
_ bin .BareEncoder = &ContactsBlockedSlice {}
_ bin .BareDecoder = &ContactsBlockedSlice {}
_ ContactsBlockedClass = &ContactsBlockedSlice {}
)
func (b *ContactsBlockedSlice ) Zero () bool {
if b == nil {
return true
}
if !(b .Count == 0 ) {
return false
}
if !(b .Blocked == nil ) {
return false
}
if !(b .Chats == nil ) {
return false
}
if !(b .Users == nil ) {
return false
}
return true
}
func (b *ContactsBlockedSlice ) String () string {
if b == nil {
return "ContactsBlockedSlice(nil)"
}
type Alias ContactsBlockedSlice
return fmt .Sprintf ("ContactsBlockedSlice%+v" , Alias (*b ))
}
func (b *ContactsBlockedSlice ) FillFrom (from interface {
GetCount () (value int )
GetBlocked () (value []PeerBlocked )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
b .Count = from .GetCount ()
b .Blocked = from .GetBlocked ()
b .Chats = from .GetChats ()
b .Users = from .GetUsers ()
}
func (*ContactsBlockedSlice ) TypeID () uint32 {
return ContactsBlockedSliceTypeID
}
func (*ContactsBlockedSlice ) TypeName () string {
return "contacts.blockedSlice"
}
func (b *ContactsBlockedSlice ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.blockedSlice" ,
ID : ContactsBlockedSliceTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Blocked" ,
SchemaName : "blocked" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (b *ContactsBlockedSlice ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode contacts.blockedSlice#e1664194 as nil" )
}
buf .PutID (ContactsBlockedSliceTypeID )
return b .EncodeBare (buf )
}
func (b *ContactsBlockedSlice ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode contacts.blockedSlice#e1664194 as nil" )
}
buf .PutInt (b .Count )
buf .PutVectorHeader (len (b .Blocked ))
for idx , v := range b .Blocked {
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.blockedSlice#e1664194: field blocked element with index %d: %w" , idx , err )
}
}
buf .PutVectorHeader (len (b .Chats ))
for idx , v := range b .Chats {
if v == nil {
return fmt .Errorf ("unable to encode contacts.blockedSlice#e1664194: field chats element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.blockedSlice#e1664194: field chats element with index %d: %w" , idx , err )
}
}
buf .PutVectorHeader (len (b .Users ))
for idx , v := range b .Users {
if v == nil {
return fmt .Errorf ("unable to encode contacts.blockedSlice#e1664194: field users element with index %d is nil" , idx )
}
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode contacts.blockedSlice#e1664194: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (b *ContactsBlockedSlice ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode contacts.blockedSlice#e1664194 to nil" )
}
if err := buf .ConsumeID (ContactsBlockedSliceTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *ContactsBlockedSlice ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode contacts.blockedSlice#e1664194 to nil" )
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: field count: %w" , err )
}
b .Count = value
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: field blocked: %w" , err )
}
if headerLen > 0 {
b .Blocked = make ([]PeerBlocked , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value PeerBlocked
if err := value .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: field blocked: %w" , err )
}
b .Blocked = append (b .Blocked , value )
}
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: field chats: %w" , err )
}
if headerLen > 0 {
b .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (buf )
if err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: field chats: %w" , err )
}
b .Chats = append (b .Chats , value )
}
}
{
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: field users: %w" , err )
}
if headerLen > 0 {
b .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (buf )
if err != nil {
return fmt .Errorf ("unable to decode contacts.blockedSlice#e1664194: field users: %w" , err )
}
b .Users = append (b .Users , value )
}
}
return nil
}
func (b *ContactsBlockedSlice ) GetCount () (value int ) {
if b == nil {
return
}
return b .Count
}
func (b *ContactsBlockedSlice ) GetBlocked () (value []PeerBlocked ) {
if b == nil {
return
}
return b .Blocked
}
func (b *ContactsBlockedSlice ) GetChats () (value []ChatClass ) {
if b == nil {
return
}
return b .Chats
}
func (b *ContactsBlockedSlice ) GetUsers () (value []UserClass ) {
if b == nil {
return
}
return b .Users
}
func (b *ContactsBlockedSlice ) MapChats () (value ChatClassArray ) {
return ChatClassArray (b .Chats )
}
func (b *ContactsBlockedSlice ) MapUsers () (value UserClassArray ) {
return UserClassArray (b .Users )
}
const ContactsBlockedClassName = "contacts.Blocked"
type ContactsBlockedClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ContactsBlockedClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetBlocked () (value []PeerBlocked )
GetChats () (value []ChatClass )
MapChats () (value ChatClassArray )
GetUsers () (value []UserClass )
MapUsers () (value UserClassArray )
}
func DecodeContactsBlocked (buf *bin .Buffer ) (ContactsBlockedClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ContactsBlockedTypeID :
v := ContactsBlocked {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ContactsBlockedClass: %w" , err )
}
return &v , nil
case ContactsBlockedSliceTypeID :
v := ContactsBlockedSlice {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ContactsBlockedClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ContactsBlockedClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ContactsBlockedBox struct {
Blocked ContactsBlockedClass
}
func (b *ContactsBlockedBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ContactsBlockedBox to nil" )
}
v , err := DecodeContactsBlocked (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Blocked = v
return nil
}
func (b *ContactsBlockedBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Blocked == nil {
return fmt .Errorf ("unable to encode ContactsBlockedClass as nil" )
}
return b .Blocked .Encode (buf )
}
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 .