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 BoolFalse struct {
}
const BoolFalseTypeID = 0xbc799737
func (b BoolFalse ) construct () BoolClass { return &b }
var (
_ bin .Encoder = &BoolFalse {}
_ bin .Decoder = &BoolFalse {}
_ bin .BareEncoder = &BoolFalse {}
_ bin .BareDecoder = &BoolFalse {}
_ BoolClass = &BoolFalse {}
)
func (b *BoolFalse ) Zero () bool {
if b == nil {
return true
}
return true
}
func (b *BoolFalse ) String () string {
if b == nil {
return "BoolFalse(nil)"
}
type Alias BoolFalse
return fmt .Sprintf ("BoolFalse%+v" , Alias (*b ))
}
func (*BoolFalse ) TypeID () uint32 {
return BoolFalseTypeID
}
func (*BoolFalse ) TypeName () string {
return "boolFalse"
}
func (b *BoolFalse ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "boolFalse" ,
ID : BoolFalseTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (b *BoolFalse ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode boolFalse#bc799737 as nil" )
}
buf .PutID (BoolFalseTypeID )
return b .EncodeBare (buf )
}
func (b *BoolFalse ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode boolFalse#bc799737 as nil" )
}
return nil
}
func (b *BoolFalse ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode boolFalse#bc799737 to nil" )
}
if err := buf .ConsumeID (BoolFalseTypeID ); err != nil {
return fmt .Errorf ("unable to decode boolFalse#bc799737: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BoolFalse ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode boolFalse#bc799737 to nil" )
}
return nil
}
type BoolTrue struct {
}
const BoolTrueTypeID = 0x997275b5
func (b BoolTrue ) construct () BoolClass { return &b }
var (
_ bin .Encoder = &BoolTrue {}
_ bin .Decoder = &BoolTrue {}
_ bin .BareEncoder = &BoolTrue {}
_ bin .BareDecoder = &BoolTrue {}
_ BoolClass = &BoolTrue {}
)
func (b *BoolTrue ) Zero () bool {
if b == nil {
return true
}
return true
}
func (b *BoolTrue ) String () string {
if b == nil {
return "BoolTrue(nil)"
}
type Alias BoolTrue
return fmt .Sprintf ("BoolTrue%+v" , Alias (*b ))
}
func (*BoolTrue ) TypeID () uint32 {
return BoolTrueTypeID
}
func (*BoolTrue ) TypeName () string {
return "boolTrue"
}
func (b *BoolTrue ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "boolTrue" ,
ID : BoolTrueTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (b *BoolTrue ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode boolTrue#997275b5 as nil" )
}
buf .PutID (BoolTrueTypeID )
return b .EncodeBare (buf )
}
func (b *BoolTrue ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode boolTrue#997275b5 as nil" )
}
return nil
}
func (b *BoolTrue ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode boolTrue#997275b5 to nil" )
}
if err := buf .ConsumeID (BoolTrueTypeID ); err != nil {
return fmt .Errorf ("unable to decode boolTrue#997275b5: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *BoolTrue ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode boolTrue#997275b5 to nil" )
}
return nil
}
const BoolClassName = "Bool"
type BoolClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () BoolClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeBool (buf *bin .Buffer ) (BoolClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case BoolFalseTypeID :
v := BoolFalse {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BoolClass: %w" , err )
}
return &v , nil
case BoolTrueTypeID :
v := BoolTrue {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode BoolClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode BoolClass: %w" , bin .NewUnexpectedID (id ))
}
}
type BoolBox struct {
Bool BoolClass
}
func (b *BoolBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode BoolBox to nil" )
}
v , err := DecodeBool (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Bool = v
return nil
}
func (b *BoolBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Bool == nil {
return fmt .Errorf ("unable to encode BoolClass as nil" )
}
return b .Bool .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 .