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 StringVector struct {
Elems []string
}
const StringVectorTypeID = bin .TypeVector
var (
_ bin .Encoder = &StringVector {}
_ bin .Decoder = &StringVector {}
_ bin .BareEncoder = &StringVector {}
_ bin .BareDecoder = &StringVector {}
)
func (vec *StringVector ) Zero () bool {
if vec == nil {
return true
}
if !(vec .Elems == nil ) {
return false
}
return true
}
func (vec *StringVector ) String () string {
if vec == nil {
return "StringVector(nil)"
}
type Alias StringVector
return fmt .Sprintf ("StringVector%+v" , Alias (*vec ))
}
func (vec *StringVector ) FillFrom (from interface {
GetElems () (value []string )
}) {
vec .Elems = from .GetElems ()
}
func (*StringVector ) TypeID () uint32 {
return StringVectorTypeID
}
func (*StringVector ) TypeName () string {
return ""
}
func (vec *StringVector ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "" ,
ID : StringVectorTypeID ,
}
if vec == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Elems" ,
SchemaName : "Elems" ,
},
}
return typ
}
func (vec *StringVector ) Encode (b *bin .Buffer ) error {
if vec == nil {
return fmt .Errorf ("can't encode Vector<string> as nil" )
}
return vec .EncodeBare (b )
}
func (vec *StringVector ) EncodeBare (b *bin .Buffer ) error {
if vec == nil {
return fmt .Errorf ("can't encode Vector<string> as nil" )
}
b .PutVectorHeader (len (vec .Elems ))
for _ , v := range vec .Elems {
b .PutString (v )
}
return nil
}
func (vec *StringVector ) Decode (b *bin .Buffer ) error {
if vec == nil {
return fmt .Errorf ("can't decode Vector<string> to nil" )
}
return vec .DecodeBare (b )
}
func (vec *StringVector ) DecodeBare (b *bin .Buffer ) error {
if vec == nil {
return fmt .Errorf ("can't decode Vector<string> to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode Vector<string>: field Elems: %w" , err )
}
if headerLen > 0 {
vec .Elems = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode Vector<string>: field Elems: %w" , err )
}
vec .Elems = append (vec .Elems , value )
}
}
return nil
}
func (vec *StringVector ) GetElems () (value []string ) {
if vec == nil {
return
}
return vec .Elems
}
The pages are generated with Golds v0.8.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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .