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 ChannelLocationEmpty struct {
}
const ChannelLocationEmptyTypeID = 0xbfb5ad8b
func (c ChannelLocationEmpty ) construct () ChannelLocationClass { return &c }
var (
_ bin .Encoder = &ChannelLocationEmpty {}
_ bin .Decoder = &ChannelLocationEmpty {}
_ bin .BareEncoder = &ChannelLocationEmpty {}
_ bin .BareDecoder = &ChannelLocationEmpty {}
_ ChannelLocationClass = &ChannelLocationEmpty {}
)
func (c *ChannelLocationEmpty ) Zero () bool {
if c == nil {
return true
}
return true
}
func (c *ChannelLocationEmpty ) String () string {
if c == nil {
return "ChannelLocationEmpty(nil)"
}
type Alias ChannelLocationEmpty
return fmt .Sprintf ("ChannelLocationEmpty%+v" , Alias (*c ))
}
func (*ChannelLocationEmpty ) TypeID () uint32 {
return ChannelLocationEmptyTypeID
}
func (*ChannelLocationEmpty ) TypeName () string {
return "channelLocationEmpty"
}
func (c *ChannelLocationEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channelLocationEmpty" ,
ID : ChannelLocationEmptyTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (c *ChannelLocationEmpty ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channelLocationEmpty#bfb5ad8b as nil" )
}
b .PutID (ChannelLocationEmptyTypeID )
return c .EncodeBare (b )
}
func (c *ChannelLocationEmpty ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channelLocationEmpty#bfb5ad8b as nil" )
}
return nil
}
func (c *ChannelLocationEmpty ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channelLocationEmpty#bfb5ad8b to nil" )
}
if err := b .ConsumeID (ChannelLocationEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode channelLocationEmpty#bfb5ad8b: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelLocationEmpty ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channelLocationEmpty#bfb5ad8b to nil" )
}
return nil
}
type ChannelLocation struct {
GeoPoint GeoPointClass
Address string
}
const ChannelLocationTypeID = 0x209b82db
func (c ChannelLocation ) construct () ChannelLocationClass { return &c }
var (
_ bin .Encoder = &ChannelLocation {}
_ bin .Decoder = &ChannelLocation {}
_ bin .BareEncoder = &ChannelLocation {}
_ bin .BareDecoder = &ChannelLocation {}
_ ChannelLocationClass = &ChannelLocation {}
)
func (c *ChannelLocation ) Zero () bool {
if c == nil {
return true
}
if !(c .GeoPoint == nil ) {
return false
}
if !(c .Address == "" ) {
return false
}
return true
}
func (c *ChannelLocation ) String () string {
if c == nil {
return "ChannelLocation(nil)"
}
type Alias ChannelLocation
return fmt .Sprintf ("ChannelLocation%+v" , Alias (*c ))
}
func (c *ChannelLocation ) FillFrom (from interface {
GetGeoPoint () (value GeoPointClass )
GetAddress () (value string )
}) {
c .GeoPoint = from .GetGeoPoint ()
c .Address = from .GetAddress ()
}
func (*ChannelLocation ) TypeID () uint32 {
return ChannelLocationTypeID
}
func (*ChannelLocation ) TypeName () string {
return "channelLocation"
}
func (c *ChannelLocation ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "channelLocation" ,
ID : ChannelLocationTypeID ,
}
if c == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "GeoPoint" ,
SchemaName : "geo_point" ,
},
{
Name : "Address" ,
SchemaName : "address" ,
},
}
return typ
}
func (c *ChannelLocation ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channelLocation#209b82db as nil" )
}
b .PutID (ChannelLocationTypeID )
return c .EncodeBare (b )
}
func (c *ChannelLocation ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode channelLocation#209b82db as nil" )
}
if c .GeoPoint == nil {
return fmt .Errorf ("unable to encode channelLocation#209b82db: field geo_point is nil" )
}
if err := c .GeoPoint .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode channelLocation#209b82db: field geo_point: %w" , err )
}
b .PutString (c .Address )
return nil
}
func (c *ChannelLocation ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channelLocation#209b82db to nil" )
}
if err := b .ConsumeID (ChannelLocationTypeID ); err != nil {
return fmt .Errorf ("unable to decode channelLocation#209b82db: %w" , err )
}
return c .DecodeBare (b )
}
func (c *ChannelLocation ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode channelLocation#209b82db to nil" )
}
{
value , err := DecodeGeoPoint (b )
if err != nil {
return fmt .Errorf ("unable to decode channelLocation#209b82db: field geo_point: %w" , err )
}
c .GeoPoint = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode channelLocation#209b82db: field address: %w" , err )
}
c .Address = value
}
return nil
}
func (c *ChannelLocation ) GetGeoPoint () (value GeoPointClass ) {
if c == nil {
return
}
return c .GeoPoint
}
func (c *ChannelLocation ) GetAddress () (value string ) {
if c == nil {
return
}
return c .Address
}
const ChannelLocationClassName = "ChannelLocation"
type ChannelLocationClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () ChannelLocationClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*ChannelLocation , bool )
}
func (c *ChannelLocationEmpty ) AsNotEmpty () (*ChannelLocation , bool ) {
return nil , false
}
func (c *ChannelLocation ) AsNotEmpty () (*ChannelLocation , bool ) {
return c , true
}
func DecodeChannelLocation (buf *bin .Buffer ) (ChannelLocationClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case ChannelLocationEmptyTypeID :
v := ChannelLocationEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChannelLocationClass: %w" , err )
}
return &v , nil
case ChannelLocationTypeID :
v := ChannelLocation {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode ChannelLocationClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode ChannelLocationClass: %w" , bin .NewUnexpectedID (id ))
}
}
type ChannelLocationBox struct {
ChannelLocation ChannelLocationClass
}
func (b *ChannelLocationBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode ChannelLocationBox to nil" )
}
v , err := DecodeChannelLocation (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .ChannelLocation = v
return nil
}
func (b *ChannelLocationBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .ChannelLocation == nil {
return fmt .Errorf ("unable to encode ChannelLocationClass as nil" )
}
return b .ChannelLocation .Encode (buf )
}
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 .