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 MessagesSearchResultsPositions struct {
Count int
Positions []SearchResultPosition
}
const MessagesSearchResultsPositionsTypeID = 0x53b22baf
var (
_ bin .Encoder = &MessagesSearchResultsPositions {}
_ bin .Decoder = &MessagesSearchResultsPositions {}
_ bin .BareEncoder = &MessagesSearchResultsPositions {}
_ bin .BareDecoder = &MessagesSearchResultsPositions {}
)
func (s *MessagesSearchResultsPositions ) Zero () bool {
if s == nil {
return true
}
if !(s .Count == 0 ) {
return false
}
if !(s .Positions == nil ) {
return false
}
return true
}
func (s *MessagesSearchResultsPositions ) String () string {
if s == nil {
return "MessagesSearchResultsPositions(nil)"
}
type Alias MessagesSearchResultsPositions
return fmt .Sprintf ("MessagesSearchResultsPositions%+v" , Alias (*s ))
}
func (s *MessagesSearchResultsPositions ) FillFrom (from interface {
GetCount () (value int )
GetPositions () (value []SearchResultPosition )
}) {
s .Count = from .GetCount ()
s .Positions = from .GetPositions ()
}
func (*MessagesSearchResultsPositions ) TypeID () uint32 {
return MessagesSearchResultsPositionsTypeID
}
func (*MessagesSearchResultsPositions ) TypeName () string {
return "messages.searchResultsPositions"
}
func (s *MessagesSearchResultsPositions ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.searchResultsPositions" ,
ID : MessagesSearchResultsPositionsTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Positions" ,
SchemaName : "positions" ,
},
}
return typ
}
func (s *MessagesSearchResultsPositions ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchResultsPositions#53b22baf as nil" )
}
b .PutID (MessagesSearchResultsPositionsTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSearchResultsPositions ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchResultsPositions#53b22baf as nil" )
}
b .PutInt (s .Count )
b .PutVectorHeader (len (s .Positions ))
for idx , v := range s .Positions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchResultsPositions#53b22baf: field positions element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *MessagesSearchResultsPositions ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchResultsPositions#53b22baf to nil" )
}
if err := b .ConsumeID (MessagesSearchResultsPositionsTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsPositions#53b22baf: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSearchResultsPositions ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchResultsPositions#53b22baf to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsPositions#53b22baf: field count: %w" , err )
}
s .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsPositions#53b22baf: field positions: %w" , err )
}
if headerLen > 0 {
s .Positions = make ([]SearchResultPosition , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value SearchResultPosition
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.searchResultsPositions#53b22baf: field positions: %w" , err )
}
s .Positions = append (s .Positions , value )
}
}
return nil
}
func (s *MessagesSearchResultsPositions ) GetCount () (value int ) {
if s == nil {
return
}
return s .Count
}
func (s *MessagesSearchResultsPositions ) GetPositions () (value []SearchResultPosition ) {
if s == nil {
return
}
return s .Positions
}
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 .