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 StarsAmount struct {
Amount int64
Nanos int
}
const StarsAmountTypeID = 0xbbb6b4a3
func (s StarsAmount ) construct () StarsAmountClass { return &s }
var (
_ bin .Encoder = &StarsAmount {}
_ bin .Decoder = &StarsAmount {}
_ bin .BareEncoder = &StarsAmount {}
_ bin .BareDecoder = &StarsAmount {}
_ StarsAmountClass = &StarsAmount {}
)
func (s *StarsAmount ) Zero () bool {
if s == nil {
return true
}
if !(s .Amount == 0 ) {
return false
}
if !(s .Nanos == 0 ) {
return false
}
return true
}
func (s *StarsAmount ) String () string {
if s == nil {
return "StarsAmount(nil)"
}
type Alias StarsAmount
return fmt .Sprintf ("StarsAmount%+v" , Alias (*s ))
}
func (s *StarsAmount ) FillFrom (from interface {
GetAmount () (value int64 )
GetNanos () (value int )
}) {
s .Amount = from .GetAmount ()
s .Nanos = from .GetNanos ()
}
func (*StarsAmount ) TypeID () uint32 {
return StarsAmountTypeID
}
func (*StarsAmount ) TypeName () string {
return "starsAmount"
}
func (s *StarsAmount ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starsAmount" ,
ID : StarsAmountTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Amount" ,
SchemaName : "amount" ,
},
{
Name : "Nanos" ,
SchemaName : "nanos" ,
},
}
return typ
}
func (s *StarsAmount ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsAmount#bbb6b4a3 as nil" )
}
b .PutID (StarsAmountTypeID )
return s .EncodeBare (b )
}
func (s *StarsAmount ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsAmount#bbb6b4a3 as nil" )
}
b .PutLong (s .Amount )
b .PutInt (s .Nanos )
return nil
}
func (s *StarsAmount ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsAmount#bbb6b4a3 to nil" )
}
if err := b .ConsumeID (StarsAmountTypeID ); err != nil {
return fmt .Errorf ("unable to decode starsAmount#bbb6b4a3: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarsAmount ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsAmount#bbb6b4a3 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starsAmount#bbb6b4a3: field amount: %w" , err )
}
s .Amount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starsAmount#bbb6b4a3: field nanos: %w" , err )
}
s .Nanos = value
}
return nil
}
func (s *StarsAmount ) GetAmount () (value int64 ) {
if s == nil {
return
}
return s .Amount
}
func (s *StarsAmount ) GetNanos () (value int ) {
if s == nil {
return
}
return s .Nanos
}
type StarsTonAmount struct {
Amount int64
}
const StarsTonAmountTypeID = 0x74aee3e0
func (s StarsTonAmount ) construct () StarsAmountClass { return &s }
var (
_ bin .Encoder = &StarsTonAmount {}
_ bin .Decoder = &StarsTonAmount {}
_ bin .BareEncoder = &StarsTonAmount {}
_ bin .BareDecoder = &StarsTonAmount {}
_ StarsAmountClass = &StarsTonAmount {}
)
func (s *StarsTonAmount ) Zero () bool {
if s == nil {
return true
}
if !(s .Amount == 0 ) {
return false
}
return true
}
func (s *StarsTonAmount ) String () string {
if s == nil {
return "StarsTonAmount(nil)"
}
type Alias StarsTonAmount
return fmt .Sprintf ("StarsTonAmount%+v" , Alias (*s ))
}
func (s *StarsTonAmount ) FillFrom (from interface {
GetAmount () (value int64 )
}) {
s .Amount = from .GetAmount ()
}
func (*StarsTonAmount ) TypeID () uint32 {
return StarsTonAmountTypeID
}
func (*StarsTonAmount ) TypeName () string {
return "starsTonAmount"
}
func (s *StarsTonAmount ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starsTonAmount" ,
ID : StarsTonAmountTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Amount" ,
SchemaName : "amount" ,
},
}
return typ
}
func (s *StarsTonAmount ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsTonAmount#74aee3e0 as nil" )
}
b .PutID (StarsTonAmountTypeID )
return s .EncodeBare (b )
}
func (s *StarsTonAmount ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsTonAmount#74aee3e0 as nil" )
}
b .PutLong (s .Amount )
return nil
}
func (s *StarsTonAmount ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsTonAmount#74aee3e0 to nil" )
}
if err := b .ConsumeID (StarsTonAmountTypeID ); err != nil {
return fmt .Errorf ("unable to decode starsTonAmount#74aee3e0: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarsTonAmount ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsTonAmount#74aee3e0 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starsTonAmount#74aee3e0: field amount: %w" , err )
}
s .Amount = value
}
return nil
}
func (s *StarsTonAmount ) GetAmount () (value int64 ) {
if s == nil {
return
}
return s .Amount
}
const StarsAmountClassName = "StarsAmount"
type StarsAmountClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () StarsAmountClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetAmount () (value int64 )
}
func DecodeStarsAmount (buf *bin .Buffer ) (StarsAmountClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case StarsAmountTypeID :
v := StarsAmount {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarsAmountClass: %w" , err )
}
return &v , nil
case StarsTonAmountTypeID :
v := StarsTonAmount {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode StarsAmountClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode StarsAmountClass: %w" , bin .NewUnexpectedID (id ))
}
}
type StarsAmountBox struct {
StarsAmount StarsAmountClass
}
func (b *StarsAmountBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode StarsAmountBox to nil" )
}
v , err := DecodeStarsAmount (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .StarsAmount = v
return nil
}
func (b *StarsAmountBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .StarsAmount == nil {
return fmt .Errorf ("unable to encode StarsAmountClass as nil" )
}
return b .StarsAmount .Encode (buf )
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .