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 InputGeoPointEmpty struct {
}
const InputGeoPointEmptyTypeID = 0xe4c123d6
func (i InputGeoPointEmpty ) construct () InputGeoPointClass { return &i }
var (
_ bin .Encoder = &InputGeoPointEmpty {}
_ bin .Decoder = &InputGeoPointEmpty {}
_ bin .BareEncoder = &InputGeoPointEmpty {}
_ bin .BareDecoder = &InputGeoPointEmpty {}
_ InputGeoPointClass = &InputGeoPointEmpty {}
)
func (i *InputGeoPointEmpty ) Zero () bool {
if i == nil {
return true
}
return true
}
func (i *InputGeoPointEmpty ) String () string {
if i == nil {
return "InputGeoPointEmpty(nil)"
}
type Alias InputGeoPointEmpty
return fmt .Sprintf ("InputGeoPointEmpty%+v" , Alias (*i ))
}
func (*InputGeoPointEmpty ) TypeID () uint32 {
return InputGeoPointEmptyTypeID
}
func (*InputGeoPointEmpty ) TypeName () string {
return "inputGeoPointEmpty"
}
func (i *InputGeoPointEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputGeoPointEmpty" ,
ID : InputGeoPointEmptyTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (i *InputGeoPointEmpty ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGeoPointEmpty#e4c123d6 as nil" )
}
b .PutID (InputGeoPointEmptyTypeID )
return i .EncodeBare (b )
}
func (i *InputGeoPointEmpty ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGeoPointEmpty#e4c123d6 as nil" )
}
return nil
}
func (i *InputGeoPointEmpty ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGeoPointEmpty#e4c123d6 to nil" )
}
if err := b .ConsumeID (InputGeoPointEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputGeoPointEmpty#e4c123d6: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputGeoPointEmpty ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGeoPointEmpty#e4c123d6 to nil" )
}
return nil
}
type InputGeoPoint struct {
Flags bin .Fields
Lat float64
Long float64
AccuracyRadius int
}
const InputGeoPointTypeID = 0x48222faf
func (i InputGeoPoint ) construct () InputGeoPointClass { return &i }
var (
_ bin .Encoder = &InputGeoPoint {}
_ bin .Decoder = &InputGeoPoint {}
_ bin .BareEncoder = &InputGeoPoint {}
_ bin .BareDecoder = &InputGeoPoint {}
_ InputGeoPointClass = &InputGeoPoint {}
)
func (i *InputGeoPoint ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Lat == 0 ) {
return false
}
if !(i .Long == 0 ) {
return false
}
if !(i .AccuracyRadius == 0 ) {
return false
}
return true
}
func (i *InputGeoPoint ) String () string {
if i == nil {
return "InputGeoPoint(nil)"
}
type Alias InputGeoPoint
return fmt .Sprintf ("InputGeoPoint%+v" , Alias (*i ))
}
func (i *InputGeoPoint ) FillFrom (from interface {
GetLat () (value float64 )
GetLong () (value float64 )
GetAccuracyRadius () (value int , ok bool )
}) {
i .Lat = from .GetLat ()
i .Long = from .GetLong ()
if val , ok := from .GetAccuracyRadius (); ok {
i .AccuracyRadius = val
}
}
func (*InputGeoPoint ) TypeID () uint32 {
return InputGeoPointTypeID
}
func (*InputGeoPoint ) TypeName () string {
return "inputGeoPoint"
}
func (i *InputGeoPoint ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputGeoPoint" ,
ID : InputGeoPointTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Lat" ,
SchemaName : "lat" ,
},
{
Name : "Long" ,
SchemaName : "long" ,
},
{
Name : "AccuracyRadius" ,
SchemaName : "accuracy_radius" ,
Null : !i .Flags .Has (0 ),
},
}
return typ
}
func (i *InputGeoPoint ) SetFlags () {
if !(i .AccuracyRadius == 0 ) {
i .Flags .Set (0 )
}
}
func (i *InputGeoPoint ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGeoPoint#48222faf as nil" )
}
b .PutID (InputGeoPointTypeID )
return i .EncodeBare (b )
}
func (i *InputGeoPoint ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputGeoPoint#48222faf as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputGeoPoint#48222faf: field flags: %w" , err )
}
b .PutDouble (i .Lat )
b .PutDouble (i .Long )
if i .Flags .Has (0 ) {
b .PutInt (i .AccuracyRadius )
}
return nil
}
func (i *InputGeoPoint ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGeoPoint#48222faf to nil" )
}
if err := b .ConsumeID (InputGeoPointTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputGeoPoint#48222faf: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputGeoPoint ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputGeoPoint#48222faf to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputGeoPoint#48222faf: field flags: %w" , err )
}
}
{
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode inputGeoPoint#48222faf: field lat: %w" , err )
}
i .Lat = value
}
{
value , err := b .Double ()
if err != nil {
return fmt .Errorf ("unable to decode inputGeoPoint#48222faf: field long: %w" , err )
}
i .Long = value
}
if i .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputGeoPoint#48222faf: field accuracy_radius: %w" , err )
}
i .AccuracyRadius = value
}
return nil
}
func (i *InputGeoPoint ) GetLat () (value float64 ) {
if i == nil {
return
}
return i .Lat
}
func (i *InputGeoPoint ) GetLong () (value float64 ) {
if i == nil {
return
}
return i .Long
}
func (i *InputGeoPoint ) SetAccuracyRadius (value int ) {
i .Flags .Set (0 )
i .AccuracyRadius = value
}
func (i *InputGeoPoint ) GetAccuracyRadius () (value int , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .AccuracyRadius , true
}
const InputGeoPointClassName = "InputGeoPoint"
type InputGeoPointClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputGeoPointClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*InputGeoPoint , bool )
}
func (i *InputGeoPointEmpty ) AsNotEmpty () (*InputGeoPoint , bool ) {
return nil , false
}
func (i *InputGeoPoint ) AsNotEmpty () (*InputGeoPoint , bool ) {
return i , true
}
func DecodeInputGeoPoint (buf *bin .Buffer ) (InputGeoPointClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputGeoPointEmptyTypeID :
v := InputGeoPointEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputGeoPointClass: %w" , err )
}
return &v , nil
case InputGeoPointTypeID :
v := InputGeoPoint {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputGeoPointClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputGeoPointClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputGeoPointBox struct {
InputGeoPoint InputGeoPointClass
}
func (b *InputGeoPointBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputGeoPointBox to nil" )
}
v , err := DecodeInputGeoPoint (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputGeoPoint = v
return nil
}
func (b *InputGeoPointBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputGeoPoint == nil {
return fmt .Errorf ("unable to encode InputGeoPointClass as nil" )
}
return b .InputGeoPoint .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 .