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 AccountReorderUsernamesRequest struct {
Order []string
}
const AccountReorderUsernamesRequestTypeID = 0xef500eab
var (
_ bin .Encoder = &AccountReorderUsernamesRequest {}
_ bin .Decoder = &AccountReorderUsernamesRequest {}
_ bin .BareEncoder = &AccountReorderUsernamesRequest {}
_ bin .BareDecoder = &AccountReorderUsernamesRequest {}
)
func (r *AccountReorderUsernamesRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Order == nil ) {
return false
}
return true
}
func (r *AccountReorderUsernamesRequest ) String () string {
if r == nil {
return "AccountReorderUsernamesRequest(nil)"
}
type Alias AccountReorderUsernamesRequest
return fmt .Sprintf ("AccountReorderUsernamesRequest%+v" , Alias (*r ))
}
func (r *AccountReorderUsernamesRequest ) FillFrom (from interface {
GetOrder () (value []string )
}) {
r .Order = from .GetOrder ()
}
func (*AccountReorderUsernamesRequest ) TypeID () uint32 {
return AccountReorderUsernamesRequestTypeID
}
func (*AccountReorderUsernamesRequest ) TypeName () string {
return "account.reorderUsernames"
}
func (r *AccountReorderUsernamesRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.reorderUsernames" ,
ID : AccountReorderUsernamesRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Order" ,
SchemaName : "order" ,
},
}
return typ
}
func (r *AccountReorderUsernamesRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode account.reorderUsernames#ef500eab as nil" )
}
b .PutID (AccountReorderUsernamesRequestTypeID )
return r .EncodeBare (b )
}
func (r *AccountReorderUsernamesRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode account.reorderUsernames#ef500eab as nil" )
}
b .PutVectorHeader (len (r .Order ))
for _ , v := range r .Order {
b .PutString (v )
}
return nil
}
func (r *AccountReorderUsernamesRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode account.reorderUsernames#ef500eab to nil" )
}
if err := b .ConsumeID (AccountReorderUsernamesRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.reorderUsernames#ef500eab: %w" , err )
}
return r .DecodeBare (b )
}
func (r *AccountReorderUsernamesRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode account.reorderUsernames#ef500eab to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.reorderUsernames#ef500eab: field order: %w" , err )
}
if headerLen > 0 {
r .Order = 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 account.reorderUsernames#ef500eab: field order: %w" , err )
}
r .Order = append (r .Order , value )
}
}
return nil
}
func (r *AccountReorderUsernamesRequest ) GetOrder () (value []string ) {
if r == nil {
return
}
return r .Order
}
func (c *Client ) AccountReorderUsernames (ctx context .Context , order []string ) (bool , error ) {
var result BoolBox
request := &AccountReorderUsernamesRequest {
Order : order ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , nil
}
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 .