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 ContactsSearchRequest struct {
Q string
Limit int
}
const ContactsSearchRequestTypeID = 0x11f812d8
var (
_ bin .Encoder = &ContactsSearchRequest {}
_ bin .Decoder = &ContactsSearchRequest {}
_ bin .BareEncoder = &ContactsSearchRequest {}
_ bin .BareDecoder = &ContactsSearchRequest {}
)
func (s *ContactsSearchRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Q == "" ) {
return false
}
if !(s .Limit == 0 ) {
return false
}
return true
}
func (s *ContactsSearchRequest ) String () string {
if s == nil {
return "ContactsSearchRequest(nil)"
}
type Alias ContactsSearchRequest
return fmt .Sprintf ("ContactsSearchRequest%+v" , Alias (*s ))
}
func (s *ContactsSearchRequest ) FillFrom (from interface {
GetQ () (value string )
GetLimit () (value int )
}) {
s .Q = from .GetQ ()
s .Limit = from .GetLimit ()
}
func (*ContactsSearchRequest ) TypeID () uint32 {
return ContactsSearchRequestTypeID
}
func (*ContactsSearchRequest ) TypeName () string {
return "contacts.search"
}
func (s *ContactsSearchRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.search" ,
ID : ContactsSearchRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Q" ,
SchemaName : "q" ,
},
{
Name : "Limit" ,
SchemaName : "limit" ,
},
}
return typ
}
func (s *ContactsSearchRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode contacts.search#11f812d8 as nil" )
}
b .PutID (ContactsSearchRequestTypeID )
return s .EncodeBare (b )
}
func (s *ContactsSearchRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode contacts.search#11f812d8 as nil" )
}
b .PutString (s .Q )
b .PutInt (s .Limit )
return nil
}
func (s *ContactsSearchRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode contacts.search#11f812d8 to nil" )
}
if err := b .ConsumeID (ContactsSearchRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.search#11f812d8: %w" , err )
}
return s .DecodeBare (b )
}
func (s *ContactsSearchRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode contacts.search#11f812d8 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.search#11f812d8: field q: %w" , err )
}
s .Q = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.search#11f812d8: field limit: %w" , err )
}
s .Limit = value
}
return nil
}
func (s *ContactsSearchRequest ) GetQ () (value string ) {
if s == nil {
return
}
return s .Q
}
func (s *ContactsSearchRequest ) GetLimit () (value int ) {
if s == nil {
return
}
return s .Limit
}
func (c *Client ) ContactsSearch (ctx context .Context , request *ContactsSearchRequest ) (*ContactsFound , error ) {
var result ContactsFound
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .