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 SecurePlainPhone struct {
Phone string
}
const SecurePlainPhoneTypeID = 0x7d6099dd
func (s SecurePlainPhone ) construct () SecurePlainDataClass { return &s }
var (
_ bin .Encoder = &SecurePlainPhone {}
_ bin .Decoder = &SecurePlainPhone {}
_ bin .BareEncoder = &SecurePlainPhone {}
_ bin .BareDecoder = &SecurePlainPhone {}
_ SecurePlainDataClass = &SecurePlainPhone {}
)
func (s *SecurePlainPhone ) Zero () bool {
if s == nil {
return true
}
if !(s .Phone == "" ) {
return false
}
return true
}
func (s *SecurePlainPhone ) String () string {
if s == nil {
return "SecurePlainPhone(nil)"
}
type Alias SecurePlainPhone
return fmt .Sprintf ("SecurePlainPhone%+v" , Alias (*s ))
}
func (s *SecurePlainPhone ) FillFrom (from interface {
GetPhone () (value string )
}) {
s .Phone = from .GetPhone ()
}
func (*SecurePlainPhone ) TypeID () uint32 {
return SecurePlainPhoneTypeID
}
func (*SecurePlainPhone ) TypeName () string {
return "securePlainPhone"
}
func (s *SecurePlainPhone ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "securePlainPhone" ,
ID : SecurePlainPhoneTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Phone" ,
SchemaName : "phone" ,
},
}
return typ
}
func (s *SecurePlainPhone ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode securePlainPhone#7d6099dd as nil" )
}
b .PutID (SecurePlainPhoneTypeID )
return s .EncodeBare (b )
}
func (s *SecurePlainPhone ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode securePlainPhone#7d6099dd as nil" )
}
b .PutString (s .Phone )
return nil
}
func (s *SecurePlainPhone ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode securePlainPhone#7d6099dd to nil" )
}
if err := b .ConsumeID (SecurePlainPhoneTypeID ); err != nil {
return fmt .Errorf ("unable to decode securePlainPhone#7d6099dd: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SecurePlainPhone ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode securePlainPhone#7d6099dd to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode securePlainPhone#7d6099dd: field phone: %w" , err )
}
s .Phone = value
}
return nil
}
func (s *SecurePlainPhone ) GetPhone () (value string ) {
if s == nil {
return
}
return s .Phone
}
type SecurePlainEmail struct {
Email string
}
const SecurePlainEmailTypeID = 0x21ec5a5f
func (s SecurePlainEmail ) construct () SecurePlainDataClass { return &s }
var (
_ bin .Encoder = &SecurePlainEmail {}
_ bin .Decoder = &SecurePlainEmail {}
_ bin .BareEncoder = &SecurePlainEmail {}
_ bin .BareDecoder = &SecurePlainEmail {}
_ SecurePlainDataClass = &SecurePlainEmail {}
)
func (s *SecurePlainEmail ) Zero () bool {
if s == nil {
return true
}
if !(s .Email == "" ) {
return false
}
return true
}
func (s *SecurePlainEmail ) String () string {
if s == nil {
return "SecurePlainEmail(nil)"
}
type Alias SecurePlainEmail
return fmt .Sprintf ("SecurePlainEmail%+v" , Alias (*s ))
}
func (s *SecurePlainEmail ) FillFrom (from interface {
GetEmail () (value string )
}) {
s .Email = from .GetEmail ()
}
func (*SecurePlainEmail ) TypeID () uint32 {
return SecurePlainEmailTypeID
}
func (*SecurePlainEmail ) TypeName () string {
return "securePlainEmail"
}
func (s *SecurePlainEmail ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "securePlainEmail" ,
ID : SecurePlainEmailTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Email" ,
SchemaName : "email" ,
},
}
return typ
}
func (s *SecurePlainEmail ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode securePlainEmail#21ec5a5f as nil" )
}
b .PutID (SecurePlainEmailTypeID )
return s .EncodeBare (b )
}
func (s *SecurePlainEmail ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode securePlainEmail#21ec5a5f as nil" )
}
b .PutString (s .Email )
return nil
}
func (s *SecurePlainEmail ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode securePlainEmail#21ec5a5f to nil" )
}
if err := b .ConsumeID (SecurePlainEmailTypeID ); err != nil {
return fmt .Errorf ("unable to decode securePlainEmail#21ec5a5f: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SecurePlainEmail ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode securePlainEmail#21ec5a5f to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode securePlainEmail#21ec5a5f: field email: %w" , err )
}
s .Email = value
}
return nil
}
func (s *SecurePlainEmail ) GetEmail () (value string ) {
if s == nil {
return
}
return s .Email
}
const SecurePlainDataClassName = "SecurePlainData"
type SecurePlainDataClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () SecurePlainDataClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeSecurePlainData (buf *bin .Buffer ) (SecurePlainDataClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case SecurePlainPhoneTypeID :
v := SecurePlainPhone {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SecurePlainDataClass: %w" , err )
}
return &v , nil
case SecurePlainEmailTypeID :
v := SecurePlainEmail {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SecurePlainDataClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode SecurePlainDataClass: %w" , bin .NewUnexpectedID (id ))
}
}
type SecurePlainDataBox struct {
SecurePlainData SecurePlainDataClass
}
func (b *SecurePlainDataBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode SecurePlainDataBox to nil" )
}
v , err := DecodeSecurePlainData (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .SecurePlainData = v
return nil
}
func (b *SecurePlainDataBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .SecurePlainData == nil {
return fmt .Errorf ("unable to encode SecurePlainDataClass as nil" )
}
return b .SecurePlainData .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 .