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 Contact struct {
UserID int64
Mutual bool
}
const ContactTypeID = 0x145ade0b
var (
_ bin .Encoder = &Contact {}
_ bin .Decoder = &Contact {}
_ bin .BareEncoder = &Contact {}
_ bin .BareDecoder = &Contact {}
)
func (c *Contact ) Zero () bool {
if c == nil {
return true
}
if !(c .UserID == 0 ) {
return false
}
if !(c .Mutual == false ) {
return false
}
return true
}
func (c *Contact ) String () string {
if c == nil {
return "Contact(nil)"
}
type Alias Contact
return fmt .Sprintf ("Contact%+v" , Alias (*c ))
}
func (c *Contact ) FillFrom (from interface {
GetUserID () (value int64 )
GetMutual () (value bool )
}) {
c .UserID = from .GetUserID ()
c .Mutual = from .GetMutual ()
}
func (*Contact ) TypeID () uint32 {
return ContactTypeID
}
func (*Contact ) TypeName () string {
return "contact"
}
func (c *Contact ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contact" ,
ID : ContactTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Mutual" ,
SchemaName : "mutual" ,
},
}
return typ
}
func (c *Contact ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contact#145ade0b as nil" )
}
b .PutID (ContactTypeID )
return c .EncodeBare (b )
}
func (c *Contact ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode contact#145ade0b as nil" )
}
b .PutLong (c .UserID )
b .PutBool (c .Mutual )
return nil
}
func (c *Contact ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contact#145ade0b to nil" )
}
if err := b .ConsumeID (ContactTypeID ); err != nil {
return fmt .Errorf ("unable to decode contact#145ade0b: %w" , err )
}
return c .DecodeBare (b )
}
func (c *Contact ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode contact#145ade0b to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode contact#145ade0b: field user_id: %w" , err )
}
c .UserID = value
}
{
value , err := b .Bool ()
if err != nil {
return fmt .Errorf ("unable to decode contact#145ade0b: field mutual: %w" , err )
}
c .Mutual = value
}
return nil
}
func (c *Contact ) GetUserID () (value int64 ) {
if c == nil {
return
}
return c .UserID
}
func (c *Contact ) GetMutual () (value bool ) {
if c == nil {
return
}
return c .Mutual
}
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 .