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 GeoPointEmpty struct {
}
const GeoPointEmptyTypeID = 0x1117dd5f
func (g GeoPointEmpty ) construct () GeoPointClass { return &g }
var (
_ bin .Encoder = &GeoPointEmpty {}
_ bin .Decoder = &GeoPointEmpty {}
_ bin .BareEncoder = &GeoPointEmpty {}
_ bin .BareDecoder = &GeoPointEmpty {}
_ GeoPointClass = &GeoPointEmpty {}
)
func (g *GeoPointEmpty ) Zero () bool {
if g == nil {
return true
}
return true
}
func (g *GeoPointEmpty ) String () string {
if g == nil {
return "GeoPointEmpty(nil)"
}
type Alias GeoPointEmpty
return fmt .Sprintf ("GeoPointEmpty%+v" , Alias (*g ))
}
func (*GeoPointEmpty ) TypeID () uint32 {
return GeoPointEmptyTypeID
}
func (*GeoPointEmpty ) TypeName () string {
return "geoPointEmpty"
}
func (g *GeoPointEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "geoPointEmpty" ,
ID : GeoPointEmptyTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (g *GeoPointEmpty ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode geoPointEmpty#1117dd5f as nil" )
}
b .PutID (GeoPointEmptyTypeID )
return g .EncodeBare (b )
}
func (g *GeoPointEmpty ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode geoPointEmpty#1117dd5f as nil" )
}
return nil
}
func (g *GeoPointEmpty ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode geoPointEmpty#1117dd5f to nil" )
}
if err := b .ConsumeID (GeoPointEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode geoPointEmpty#1117dd5f: %w" , err )
}
return g .DecodeBare (b )
}
func (g *GeoPointEmpty ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode geoPointEmpty#1117dd5f to nil" )
}
return nil
}
type GeoPoint struct {
Flags bin .Fields
Long float64
Lat float64
AccessHash int64
AccuracyRadius int
}
const GeoPointTypeID = 0xb2a2f663
func (g GeoPoint ) construct () GeoPointClass { return &g }
var (
_ bin .Encoder = &GeoPoint {}
_ bin .Decoder = &GeoPoint {}
_ bin .BareEncoder = &GeoPoint {}
_ bin .BareDecoder = &GeoPoint {}
_ GeoPointClass = &GeoPoint {}
)
func (g *GeoPoint ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Long == 0 ) {
return false
}
if !(g .Lat == 0 ) {
return false
}
if !(g .AccessHash == 0 ) {
return false
}
if !(g .AccuracyRadius == 0 ) {
return false
}
return true
}
func (g *GeoPoint ) String () string {
if g == nil {
return "GeoPoint(nil)"
}
type Alias GeoPoint
return fmt .Sprintf ("GeoPoint%+v" , Alias (*g ))
}
func (g *GeoPoint ) FillFrom (from interface {
GetLong () (value float64 )
GetLat () (value float64 )
GetAccessHash () (value int64 )
GetAccuracyRadius () (value int , ok bool )
}) {
g .Long = from .GetLong ()
g .Lat = from .GetLat ()
g .AccessHash = from .GetAccessHash ()
if val , ok := from .GetAccuracyRadius (); ok {
g .AccuracyRadius = val
}
}
func (*GeoPoint ) TypeID () uint32 {
return GeoPointTypeID
}
func (*GeoPoint ) TypeName () string {
return "geoPoint"
}
func (g *GeoPoint ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "geoPoint" ,
ID : GeoPointTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Long" ,
SchemaName : "long" ,
},
{
Name : "Lat" ,
SchemaName : "lat" ,
},
{
Name : "AccessHash" ,
SchemaName : "access_hash" ,
},
{
Name : "AccuracyRadius" ,
SchemaName : "accuracy_radius" ,
Null : !g .Flags .Has (0 ),
},
}
return typ
}
func (g *GeoPoint ) SetFlags () {
if !(g .AccuracyRadius == 0 ) {
g .Flags .Set (0 )
}
}
func (g *GeoPoint ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode geoPoint#b2a2f663 as nil" )
}
b .PutID (GeoPointTypeID )
return g .EncodeBare (b )
}
func (g *GeoPoint ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode geoPoint#b2a2f663 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode geoPoint#b2a2f663: field flags: %w" , err )
}
b .PutDouble (g .Long )
b .PutDouble (g .Lat )
b .PutLong (g .AccessHash )
if g .Flags .Has (0 ) {
b .PutInt (g .AccuracyRadius )
}
return nil
}
func (g *GeoPoint ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode geoPoint#b2a2f663 to nil" )
}
if err := b .ConsumeID (GeoPointTypeID ); err != nil {
return fmt .Errorf ("unable to decode geoPoint#b2a2f663: %w" , err )
}
return g .DecodeBare (b )
}
func (g *GeoPoint ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode geoPoint#b2a2f663 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode geoPoint#b2a2f663: field flags: %w" , err )
}
}
{
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode geoPoint#b2a2f663: field long: %w" , err )
}
g .Long = value
}
{
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode geoPoint#b2a2f663: field lat: %w" , err )
}
g .Lat = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode geoPoint#b2a2f663: field access_hash: %w" , err )
}
g .AccessHash = value
}
if g .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode geoPoint#b2a2f663: field accuracy_radius: %w" , err )
}
g .AccuracyRadius = value
}
return nil
}
func (g *GeoPoint ) GetLong () (value float64 ) {
if g == nil {
return
}
return g .Long
}
func (g *GeoPoint ) GetLat () (value float64 ) {
if g == nil {
return
}
return g .Lat
}
func (g *GeoPoint ) GetAccessHash () (value int64 ) {
if g == nil {
return
}
return g .AccessHash
}
func (g *GeoPoint ) SetAccuracyRadius (value int ) {
g .Flags .Set (0 )
g .AccuracyRadius = value
}
func (g *GeoPoint ) GetAccuracyRadius () (value int , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .AccuracyRadius , true
}
const GeoPointClassName = "GeoPoint"
type GeoPointClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () GeoPointClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*GeoPoint , bool )
}
func (g *GeoPointEmpty ) AsNotEmpty () (*GeoPoint , bool ) {
return nil , false
}
func (g *GeoPoint ) AsNotEmpty () (*GeoPoint , bool ) {
return g , true
}
func DecodeGeoPoint (buf *bin .Buffer ) (GeoPointClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case GeoPointEmptyTypeID :
v := GeoPointEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode GeoPointClass: %w" , err )
}
return &v , nil
case GeoPointTypeID :
v := GeoPoint {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode GeoPointClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode GeoPointClass: %w" , bin .NewUnexpectedID (id ))
}
}
type GeoPointBox struct {
GeoPoint GeoPointClass
}
func (b *GeoPointBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode GeoPointBox to nil" )
}
v , err := DecodeGeoPoint (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .GeoPoint = v
return nil
}
func (b *GeoPointBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .GeoPoint == nil {
return fmt .Errorf ("unable to encode GeoPointClass as nil" )
}
return b .GeoPoint .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 .