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 PhoneConnection struct {
Flags bin .Fields
TCP bool
ID int64
IP string
Ipv6 string
Port int
PeerTag []byte
}
const PhoneConnectionTypeID = 0x9cc123c7
func (p PhoneConnection ) construct () PhoneConnectionClass { return &p }
var (
_ bin .Encoder = &PhoneConnection {}
_ bin .Decoder = &PhoneConnection {}
_ bin .BareEncoder = &PhoneConnection {}
_ bin .BareDecoder = &PhoneConnection {}
_ PhoneConnectionClass = &PhoneConnection {}
)
func (p *PhoneConnection ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .TCP == false ) {
return false
}
if !(p .ID == 0 ) {
return false
}
if !(p .IP == "" ) {
return false
}
if !(p .Ipv6 == "" ) {
return false
}
if !(p .Port == 0 ) {
return false
}
if !(p .PeerTag == nil ) {
return false
}
return true
}
func (p *PhoneConnection ) String () string {
if p == nil {
return "PhoneConnection(nil)"
}
type Alias PhoneConnection
return fmt .Sprintf ("PhoneConnection%+v" , Alias (*p ))
}
func (p *PhoneConnection ) FillFrom (from interface {
GetTCP () (value bool )
GetID () (value int64 )
GetIP () (value string )
GetIpv6 () (value string )
GetPort () (value int )
GetPeerTag () (value []byte )
}) {
p .TCP = from .GetTCP ()
p .ID = from .GetID ()
p .IP = from .GetIP ()
p .Ipv6 = from .GetIpv6 ()
p .Port = from .GetPort ()
p .PeerTag = from .GetPeerTag ()
}
func (*PhoneConnection ) TypeID () uint32 {
return PhoneConnectionTypeID
}
func (*PhoneConnection ) TypeName () string {
return "phoneConnection"
}
func (p *PhoneConnection ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phoneConnection" ,
ID : PhoneConnectionTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "TCP" ,
SchemaName : "tcp" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "IP" ,
SchemaName : "ip" ,
},
{
Name : "Ipv6" ,
SchemaName : "ipv6" ,
},
{
Name : "Port" ,
SchemaName : "port" ,
},
{
Name : "PeerTag" ,
SchemaName : "peer_tag" ,
},
}
return typ
}
func (p *PhoneConnection ) SetFlags () {
if !(p .TCP == false ) {
p .Flags .Set (0 )
}
}
func (p *PhoneConnection ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode phoneConnection#9cc123c7 as nil" )
}
b .PutID (PhoneConnectionTypeID )
return p .EncodeBare (b )
}
func (p *PhoneConnection ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode phoneConnection#9cc123c7 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phoneConnection#9cc123c7: field flags: %w" , err )
}
b .PutLong (p .ID )
b .PutString (p .IP )
b .PutString (p .Ipv6 )
b .PutInt (p .Port )
b .PutBytes (p .PeerTag )
return nil
}
func (p *PhoneConnection ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode phoneConnection#9cc123c7 to nil" )
}
if err := b .ConsumeID (PhoneConnectionTypeID ); err != nil {
return fmt .Errorf ("unable to decode phoneConnection#9cc123c7: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhoneConnection ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode phoneConnection#9cc123c7 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phoneConnection#9cc123c7: field flags: %w" , err )
}
}
p .TCP = p .Flags .Has (0 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnection#9cc123c7: field id: %w" , err )
}
p .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnection#9cc123c7: field ip: %w" , err )
}
p .IP = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnection#9cc123c7: field ipv6: %w" , err )
}
p .Ipv6 = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnection#9cc123c7: field port: %w" , err )
}
p .Port = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnection#9cc123c7: field peer_tag: %w" , err )
}
p .PeerTag = value
}
return nil
}
func (p *PhoneConnection ) SetTCP (value bool ) {
if value {
p .Flags .Set (0 )
p .TCP = true
} else {
p .Flags .Unset (0 )
p .TCP = false
}
}
func (p *PhoneConnection ) GetTCP () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (0 )
}
func (p *PhoneConnection ) GetID () (value int64 ) {
if p == nil {
return
}
return p .ID
}
func (p *PhoneConnection ) GetIP () (value string ) {
if p == nil {
return
}
return p .IP
}
func (p *PhoneConnection ) GetIpv6 () (value string ) {
if p == nil {
return
}
return p .Ipv6
}
func (p *PhoneConnection ) GetPort () (value int ) {
if p == nil {
return
}
return p .Port
}
func (p *PhoneConnection ) GetPeerTag () (value []byte ) {
if p == nil {
return
}
return p .PeerTag
}
type PhoneConnectionWebrtc struct {
Flags bin .Fields
Turn bool
Stun bool
ID int64
IP string
Ipv6 string
Port int
Username string
Password string
}
const PhoneConnectionWebrtcTypeID = 0x635fe375
func (p PhoneConnectionWebrtc ) construct () PhoneConnectionClass { return &p }
var (
_ bin .Encoder = &PhoneConnectionWebrtc {}
_ bin .Decoder = &PhoneConnectionWebrtc {}
_ bin .BareEncoder = &PhoneConnectionWebrtc {}
_ bin .BareDecoder = &PhoneConnectionWebrtc {}
_ PhoneConnectionClass = &PhoneConnectionWebrtc {}
)
func (p *PhoneConnectionWebrtc ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Turn == false ) {
return false
}
if !(p .Stun == false ) {
return false
}
if !(p .ID == 0 ) {
return false
}
if !(p .IP == "" ) {
return false
}
if !(p .Ipv6 == "" ) {
return false
}
if !(p .Port == 0 ) {
return false
}
if !(p .Username == "" ) {
return false
}
if !(p .Password == "" ) {
return false
}
return true
}
func (p *PhoneConnectionWebrtc ) String () string {
if p == nil {
return "PhoneConnectionWebrtc(nil)"
}
type Alias PhoneConnectionWebrtc
return fmt .Sprintf ("PhoneConnectionWebrtc%+v" , Alias (*p ))
}
func (p *PhoneConnectionWebrtc ) FillFrom (from interface {
GetTurn () (value bool )
GetStun () (value bool )
GetID () (value int64 )
GetIP () (value string )
GetIpv6 () (value string )
GetPort () (value int )
GetUsername () (value string )
GetPassword () (value string )
}) {
p .Turn = from .GetTurn ()
p .Stun = from .GetStun ()
p .ID = from .GetID ()
p .IP = from .GetIP ()
p .Ipv6 = from .GetIpv6 ()
p .Port = from .GetPort ()
p .Username = from .GetUsername ()
p .Password = from .GetPassword ()
}
func (*PhoneConnectionWebrtc ) TypeID () uint32 {
return PhoneConnectionWebrtcTypeID
}
func (*PhoneConnectionWebrtc ) TypeName () string {
return "phoneConnectionWebrtc"
}
func (p *PhoneConnectionWebrtc ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phoneConnectionWebrtc" ,
ID : PhoneConnectionWebrtcTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Turn" ,
SchemaName : "turn" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "Stun" ,
SchemaName : "stun" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "IP" ,
SchemaName : "ip" ,
},
{
Name : "Ipv6" ,
SchemaName : "ipv6" ,
},
{
Name : "Port" ,
SchemaName : "port" ,
},
{
Name : "Username" ,
SchemaName : "username" ,
},
{
Name : "Password" ,
SchemaName : "password" ,
},
}
return typ
}
func (p *PhoneConnectionWebrtc ) SetFlags () {
if !(p .Turn == false ) {
p .Flags .Set (0 )
}
if !(p .Stun == false ) {
p .Flags .Set (1 )
}
}
func (p *PhoneConnectionWebrtc ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode phoneConnectionWebrtc#635fe375 as nil" )
}
b .PutID (PhoneConnectionWebrtcTypeID )
return p .EncodeBare (b )
}
func (p *PhoneConnectionWebrtc ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode phoneConnectionWebrtc#635fe375 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phoneConnectionWebrtc#635fe375: field flags: %w" , err )
}
b .PutLong (p .ID )
b .PutString (p .IP )
b .PutString (p .Ipv6 )
b .PutInt (p .Port )
b .PutString (p .Username )
b .PutString (p .Password )
return nil
}
func (p *PhoneConnectionWebrtc ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode phoneConnectionWebrtc#635fe375 to nil" )
}
if err := b .ConsumeID (PhoneConnectionWebrtcTypeID ); err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhoneConnectionWebrtc ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode phoneConnectionWebrtc#635fe375 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: field flags: %w" , err )
}
}
p .Turn = p .Flags .Has (0 )
p .Stun = p .Flags .Has (1 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: field id: %w" , err )
}
p .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: field ip: %w" , err )
}
p .IP = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: field ipv6: %w" , err )
}
p .Ipv6 = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: field port: %w" , err )
}
p .Port = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: field username: %w" , err )
}
p .Username = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phoneConnectionWebrtc#635fe375: field password: %w" , err )
}
p .Password = value
}
return nil
}
func (p *PhoneConnectionWebrtc ) SetTurn (value bool ) {
if value {
p .Flags .Set (0 )
p .Turn = true
} else {
p .Flags .Unset (0 )
p .Turn = false
}
}
func (p *PhoneConnectionWebrtc ) GetTurn () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (0 )
}
func (p *PhoneConnectionWebrtc ) SetStun (value bool ) {
if value {
p .Flags .Set (1 )
p .Stun = true
} else {
p .Flags .Unset (1 )
p .Stun = false
}
}
func (p *PhoneConnectionWebrtc ) GetStun () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (1 )
}
func (p *PhoneConnectionWebrtc ) GetID () (value int64 ) {
if p == nil {
return
}
return p .ID
}
func (p *PhoneConnectionWebrtc ) GetIP () (value string ) {
if p == nil {
return
}
return p .IP
}
func (p *PhoneConnectionWebrtc ) GetIpv6 () (value string ) {
if p == nil {
return
}
return p .Ipv6
}
func (p *PhoneConnectionWebrtc ) GetPort () (value int ) {
if p == nil {
return
}
return p .Port
}
func (p *PhoneConnectionWebrtc ) GetUsername () (value string ) {
if p == nil {
return
}
return p .Username
}
func (p *PhoneConnectionWebrtc ) GetPassword () (value string ) {
if p == nil {
return
}
return p .Password
}
const PhoneConnectionClassName = "PhoneConnection"
type PhoneConnectionClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PhoneConnectionClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
GetIP () (value string )
GetIpv6 () (value string )
GetPort () (value int )
}
func DecodePhoneConnection (buf *bin .Buffer ) (PhoneConnectionClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PhoneConnectionTypeID :
v := PhoneConnection {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhoneConnectionClass: %w" , err )
}
return &v , nil
case PhoneConnectionWebrtcTypeID :
v := PhoneConnectionWebrtc {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhoneConnectionClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PhoneConnectionClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PhoneConnectionBox struct {
PhoneConnection PhoneConnectionClass
}
func (b *PhoneConnectionBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PhoneConnectionBox to nil" )
}
v , err := DecodePhoneConnection (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .PhoneConnection = v
return nil
}
func (b *PhoneConnectionBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .PhoneConnection == nil {
return fmt .Errorf ("unable to encode PhoneConnectionClass as nil" )
}
return b .PhoneConnection .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 .