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 LangPackDifference struct {
LangCode string
FromVersion int
Version int
Strings []LangPackStringClass
}
const LangPackDifferenceTypeID = 0xf385c1f6
var (
_ bin .Encoder = &LangPackDifference {}
_ bin .Decoder = &LangPackDifference {}
_ bin .BareEncoder = &LangPackDifference {}
_ bin .BareDecoder = &LangPackDifference {}
)
func (l *LangPackDifference ) Zero () bool {
if l == nil {
return true
}
if !(l .LangCode == "" ) {
return false
}
if !(l .FromVersion == 0 ) {
return false
}
if !(l .Version == 0 ) {
return false
}
if !(l .Strings == nil ) {
return false
}
return true
}
func (l *LangPackDifference ) String () string {
if l == nil {
return "LangPackDifference(nil)"
}
type Alias LangPackDifference
return fmt .Sprintf ("LangPackDifference%+v" , Alias (*l ))
}
func (l *LangPackDifference ) FillFrom (from interface {
GetLangCode () (value string )
GetFromVersion () (value int )
GetVersion () (value int )
GetStrings () (value []LangPackStringClass )
}) {
l .LangCode = from .GetLangCode ()
l .FromVersion = from .GetFromVersion ()
l .Version = from .GetVersion ()
l .Strings = from .GetStrings ()
}
func (*LangPackDifference ) TypeID () uint32 {
return LangPackDifferenceTypeID
}
func (*LangPackDifference ) TypeName () string {
return "langPackDifference"
}
func (l *LangPackDifference ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "langPackDifference" ,
ID : LangPackDifferenceTypeID ,
}
if l == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "LangCode" ,
SchemaName : "lang_code" ,
},
{
Name : "FromVersion" ,
SchemaName : "from_version" ,
},
{
Name : "Version" ,
SchemaName : "version" ,
},
{
Name : "Strings" ,
SchemaName : "strings" ,
},
}
return typ
}
func (l *LangPackDifference ) Encode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode langPackDifference#f385c1f6 as nil" )
}
b .PutID (LangPackDifferenceTypeID )
return l .EncodeBare (b )
}
func (l *LangPackDifference ) EncodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode langPackDifference#f385c1f6 as nil" )
}
b .PutString (l .LangCode )
b .PutInt (l .FromVersion )
b .PutInt (l .Version )
b .PutVectorHeader (len (l .Strings ))
for idx , v := range l .Strings {
if v == nil {
return fmt .Errorf ("unable to encode langPackDifference#f385c1f6: field strings element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode langPackDifference#f385c1f6: field strings element with index %d: %w" , idx , err )
}
}
return nil
}
func (l *LangPackDifference ) Decode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode langPackDifference#f385c1f6 to nil" )
}
if err := b .ConsumeID (LangPackDifferenceTypeID ); err != nil {
return fmt .Errorf ("unable to decode langPackDifference#f385c1f6: %w" , err )
}
return l .DecodeBare (b )
}
func (l *LangPackDifference ) DecodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode langPackDifference#f385c1f6 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode langPackDifference#f385c1f6: field lang_code: %w" , err )
}
l .LangCode = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode langPackDifference#f385c1f6: field from_version: %w" , err )
}
l .FromVersion = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode langPackDifference#f385c1f6: field version: %w" , err )
}
l .Version = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode langPackDifference#f385c1f6: field strings: %w" , err )
}
if headerLen > 0 {
l .Strings = make ([]LangPackStringClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeLangPackString (b )
if err != nil {
return fmt .Errorf ("unable to decode langPackDifference#f385c1f6: field strings: %w" , err )
}
l .Strings = append (l .Strings , value )
}
}
return nil
}
func (l *LangPackDifference ) GetLangCode () (value string ) {
if l == nil {
return
}
return l .LangCode
}
func (l *LangPackDifference ) GetFromVersion () (value int ) {
if l == nil {
return
}
return l .FromVersion
}
func (l *LangPackDifference ) GetVersion () (value int ) {
if l == nil {
return
}
return l .Version
}
func (l *LangPackDifference ) GetStrings () (value []LangPackStringClass ) {
if l == nil {
return
}
return l .Strings
}
func (l *LangPackDifference ) MapStrings () (value LangPackStringClassArray ) {
return LangPackStringClassArray (l .Strings )
}
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 .