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 PhoneCallProtocol struct {
Flags bin .Fields
UDPP2P bool
UDPReflector bool
MinLayer int
MaxLayer int
LibraryVersions []string
}
const PhoneCallProtocolTypeID = 0xfc878fc8
var (
_ bin .Encoder = &PhoneCallProtocol {}
_ bin .Decoder = &PhoneCallProtocol {}
_ bin .BareEncoder = &PhoneCallProtocol {}
_ bin .BareDecoder = &PhoneCallProtocol {}
)
func (p *PhoneCallProtocol ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .UDPP2P == false ) {
return false
}
if !(p .UDPReflector == false ) {
return false
}
if !(p .MinLayer == 0 ) {
return false
}
if !(p .MaxLayer == 0 ) {
return false
}
if !(p .LibraryVersions == nil ) {
return false
}
return true
}
func (p *PhoneCallProtocol ) String () string {
if p == nil {
return "PhoneCallProtocol(nil)"
}
type Alias PhoneCallProtocol
return fmt .Sprintf ("PhoneCallProtocol%+v" , Alias (*p ))
}
func (p *PhoneCallProtocol ) FillFrom (from interface {
GetUDPP2P () (value bool )
GetUDPReflector () (value bool )
GetMinLayer () (value int )
GetMaxLayer () (value int )
GetLibraryVersions () (value []string )
}) {
p .UDPP2P = from .GetUDPP2P ()
p .UDPReflector = from .GetUDPReflector ()
p .MinLayer = from .GetMinLayer ()
p .MaxLayer = from .GetMaxLayer ()
p .LibraryVersions = from .GetLibraryVersions ()
}
func (*PhoneCallProtocol ) TypeID () uint32 {
return PhoneCallProtocolTypeID
}
func (*PhoneCallProtocol ) TypeName () string {
return "phoneCallProtocol"
}
func (p *PhoneCallProtocol ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "phoneCallProtocol" ,
ID : PhoneCallProtocolTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UDPP2P" ,
SchemaName : "udp_p2p" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "UDPReflector" ,
SchemaName : "udp_reflector" ,
Null : !p .Flags .Has (1 ),
},
{
Name : "MinLayer" ,
SchemaName : "min_layer" ,
},
{
Name : "MaxLayer" ,
SchemaName : "max_layer" ,
},
{
Name : "LibraryVersions" ,
SchemaName : "library_versions" ,
},
}
return typ
}
func (p *PhoneCallProtocol ) SetFlags () {
if !(p .UDPP2P == false ) {
p .Flags .Set (0 )
}
if !(p .UDPReflector == false ) {
p .Flags .Set (1 )
}
}
func (p *PhoneCallProtocol ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode phoneCallProtocol#fc878fc8 as nil" )
}
b .PutID (PhoneCallProtocolTypeID )
return p .EncodeBare (b )
}
func (p *PhoneCallProtocol ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode phoneCallProtocol#fc878fc8 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode phoneCallProtocol#fc878fc8: field flags: %w" , err )
}
b .PutInt (p .MinLayer )
b .PutInt (p .MaxLayer )
b .PutVectorHeader (len (p .LibraryVersions ))
for _ , v := range p .LibraryVersions {
b .PutString (v )
}
return nil
}
func (p *PhoneCallProtocol ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode phoneCallProtocol#fc878fc8 to nil" )
}
if err := b .ConsumeID (PhoneCallProtocolTypeID ); err != nil {
return fmt .Errorf ("unable to decode phoneCallProtocol#fc878fc8: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhoneCallProtocol ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode phoneCallProtocol#fc878fc8 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode phoneCallProtocol#fc878fc8: field flags: %w" , err )
}
}
p .UDPP2P = p .Flags .Has (0 )
p .UDPReflector = p .Flags .Has (1 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phoneCallProtocol#fc878fc8: field min_layer: %w" , err )
}
p .MinLayer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode phoneCallProtocol#fc878fc8: field max_layer: %w" , err )
}
p .MaxLayer = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode phoneCallProtocol#fc878fc8: field library_versions: %w" , err )
}
if headerLen > 0 {
p .LibraryVersions = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode phoneCallProtocol#fc878fc8: field library_versions: %w" , err )
}
p .LibraryVersions = append (p .LibraryVersions , value )
}
}
return nil
}
func (p *PhoneCallProtocol ) SetUDPP2P (value bool ) {
if value {
p .Flags .Set (0 )
p .UDPP2P = true
} else {
p .Flags .Unset (0 )
p .UDPP2P = false
}
}
func (p *PhoneCallProtocol ) GetUDPP2P () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (0 )
}
func (p *PhoneCallProtocol ) SetUDPReflector (value bool ) {
if value {
p .Flags .Set (1 )
p .UDPReflector = true
} else {
p .Flags .Unset (1 )
p .UDPReflector = false
}
}
func (p *PhoneCallProtocol ) GetUDPReflector () (value bool ) {
if p == nil {
return
}
return p .Flags .Has (1 )
}
func (p *PhoneCallProtocol ) GetMinLayer () (value int ) {
if p == nil {
return
}
return p .MinLayer
}
func (p *PhoneCallProtocol ) GetMaxLayer () (value int ) {
if p == nil {
return
}
return p .MaxLayer
}
func (p *PhoneCallProtocol ) GetLibraryVersions () (value []string ) {
if p == nil {
return
}
return p .LibraryVersions
}
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 .