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 MessagesSearchCounter struct {
Flags bin .Fields
Inexact bool
Filter MessagesFilterClass
Count int
}
const MessagesSearchCounterTypeID = 0xe844ebff
var (
_ bin .Encoder = &MessagesSearchCounter {}
_ bin .Decoder = &MessagesSearchCounter {}
_ bin .BareEncoder = &MessagesSearchCounter {}
_ bin .BareDecoder = &MessagesSearchCounter {}
)
func (s *MessagesSearchCounter ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Inexact == false ) {
return false
}
if !(s .Filter == nil ) {
return false
}
if !(s .Count == 0 ) {
return false
}
return true
}
func (s *MessagesSearchCounter ) String () string {
if s == nil {
return "MessagesSearchCounter(nil)"
}
type Alias MessagesSearchCounter
return fmt .Sprintf ("MessagesSearchCounter%+v" , Alias (*s ))
}
func (s *MessagesSearchCounter ) FillFrom (from interface {
GetInexact () (value bool )
GetFilter () (value MessagesFilterClass )
GetCount () (value int )
}) {
s .Inexact = from .GetInexact ()
s .Filter = from .GetFilter ()
s .Count = from .GetCount ()
}
func (*MessagesSearchCounter ) TypeID () uint32 {
return MessagesSearchCounterTypeID
}
func (*MessagesSearchCounter ) TypeName () string {
return "messages.searchCounter"
}
func (s *MessagesSearchCounter ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "messages.searchCounter" ,
ID : MessagesSearchCounterTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Inexact" ,
SchemaName : "inexact" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Filter" ,
SchemaName : "filter" ,
},
{
Name : "Count" ,
SchemaName : "count" ,
},
}
return typ
}
func (s *MessagesSearchCounter ) SetFlags () {
if !(s .Inexact == false ) {
s .Flags .Set (1 )
}
}
func (s *MessagesSearchCounter ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchCounter#e844ebff as nil" )
}
b .PutID (MessagesSearchCounterTypeID )
return s .EncodeBare (b )
}
func (s *MessagesSearchCounter ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode messages.searchCounter#e844ebff as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchCounter#e844ebff: field flags: %w" , err )
}
if s .Filter == nil {
return fmt .Errorf ("unable to encode messages.searchCounter#e844ebff: field filter is nil" )
}
if err := s .Filter .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode messages.searchCounter#e844ebff: field filter: %w" , err )
}
b .PutInt (s .Count )
return nil
}
func (s *MessagesSearchCounter ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchCounter#e844ebff to nil" )
}
if err := b .ConsumeID (MessagesSearchCounterTypeID ); err != nil {
return fmt .Errorf ("unable to decode messages.searchCounter#e844ebff: %w" , err )
}
return s .DecodeBare (b )
}
func (s *MessagesSearchCounter ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode messages.searchCounter#e844ebff to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode messages.searchCounter#e844ebff: field flags: %w" , err )
}
}
s .Inexact = s .Flags .Has (1 )
{
value , err := DecodeMessagesFilter (b )
if err != nil {
return fmt .Errorf ("unable to decode messages.searchCounter#e844ebff: field filter: %w" , err )
}
s .Filter = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode messages.searchCounter#e844ebff: field count: %w" , err )
}
s .Count = value
}
return nil
}
func (s *MessagesSearchCounter ) SetInexact (value bool ) {
if value {
s .Flags .Set (1 )
s .Inexact = true
} else {
s .Flags .Unset (1 )
s .Inexact = false
}
}
func (s *MessagesSearchCounter ) GetInexact () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *MessagesSearchCounter ) GetFilter () (value MessagesFilterClass ) {
if s == nil {
return
}
return s .Filter
}
func (s *MessagesSearchCounter ) GetCount () (value int ) {
if s == nil {
return
}
return s .Count
}
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 .