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