package mt
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 DhGenOk struct {
Nonce bin .Int128
ServerNonce bin .Int128
NewNonceHash1 bin .Int128
}
const DhGenOkTypeID = 0x3bcbf734
func (d DhGenOk ) construct () SetClientDHParamsAnswerClass { return &d }
var (
_ bin .Encoder = &DhGenOk {}
_ bin .Decoder = &DhGenOk {}
_ bin .BareEncoder = &DhGenOk {}
_ bin .BareDecoder = &DhGenOk {}
_ SetClientDHParamsAnswerClass = &DhGenOk {}
)
func (d *DhGenOk ) Zero () bool {
if d == nil {
return true
}
if !(d .Nonce == bin .Int128 {}) {
return false
}
if !(d .ServerNonce == bin .Int128 {}) {
return false
}
if !(d .NewNonceHash1 == bin .Int128 {}) {
return false
}
return true
}
func (d *DhGenOk ) String () string {
if d == nil {
return "DhGenOk(nil)"
}
type Alias DhGenOk
return fmt .Sprintf ("DhGenOk%+v" , Alias (*d ))
}
func (*DhGenOk ) TypeID () uint32 {
return DhGenOkTypeID
}
func (*DhGenOk ) TypeName () string {
return "dh_gen_ok"
}
func (d *DhGenOk ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "dh_gen_ok" ,
ID : DhGenOkTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Nonce" ,
SchemaName : "nonce" ,
},
{
Name : "ServerNonce" ,
SchemaName : "server_nonce" ,
},
{
Name : "NewNonceHash1" ,
SchemaName : "new_nonce_hash1" ,
},
}
return typ
}
func (d *DhGenOk ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dh_gen_ok#3bcbf734 as nil" )
}
b .PutID (DhGenOkTypeID )
return d .EncodeBare (b )
}
func (d *DhGenOk ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dh_gen_ok#3bcbf734 as nil" )
}
b .PutInt128 (d .Nonce )
b .PutInt128 (d .ServerNonce )
b .PutInt128 (d .NewNonceHash1 )
return nil
}
func (d *DhGenOk ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dh_gen_ok#3bcbf734 to nil" )
}
if err := b .ConsumeID (DhGenOkTypeID ); err != nil {
return fmt .Errorf ("unable to decode dh_gen_ok#3bcbf734: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DhGenOk ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dh_gen_ok#3bcbf734 to nil" )
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_ok#3bcbf734: field nonce: %w" , err )
}
d .Nonce = value
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_ok#3bcbf734: field server_nonce: %w" , err )
}
d .ServerNonce = value
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_ok#3bcbf734: field new_nonce_hash1: %w" , err )
}
d .NewNonceHash1 = value
}
return nil
}
func (d *DhGenOk ) GetNonce () (value bin .Int128 ) {
if d == nil {
return
}
return d .Nonce
}
func (d *DhGenOk ) GetServerNonce () (value bin .Int128 ) {
if d == nil {
return
}
return d .ServerNonce
}
func (d *DhGenOk ) GetNewNonceHash1 () (value bin .Int128 ) {
if d == nil {
return
}
return d .NewNonceHash1
}
type DhGenRetry struct {
Nonce bin .Int128
ServerNonce bin .Int128
NewNonceHash2 bin .Int128
}
const DhGenRetryTypeID = 0x46dc1fb9
func (d DhGenRetry ) construct () SetClientDHParamsAnswerClass { return &d }
var (
_ bin .Encoder = &DhGenRetry {}
_ bin .Decoder = &DhGenRetry {}
_ bin .BareEncoder = &DhGenRetry {}
_ bin .BareDecoder = &DhGenRetry {}
_ SetClientDHParamsAnswerClass = &DhGenRetry {}
)
func (d *DhGenRetry ) Zero () bool {
if d == nil {
return true
}
if !(d .Nonce == bin .Int128 {}) {
return false
}
if !(d .ServerNonce == bin .Int128 {}) {
return false
}
if !(d .NewNonceHash2 == bin .Int128 {}) {
return false
}
return true
}
func (d *DhGenRetry ) String () string {
if d == nil {
return "DhGenRetry(nil)"
}
type Alias DhGenRetry
return fmt .Sprintf ("DhGenRetry%+v" , Alias (*d ))
}
func (*DhGenRetry ) TypeID () uint32 {
return DhGenRetryTypeID
}
func (*DhGenRetry ) TypeName () string {
return "dh_gen_retry"
}
func (d *DhGenRetry ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "dh_gen_retry" ,
ID : DhGenRetryTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Nonce" ,
SchemaName : "nonce" ,
},
{
Name : "ServerNonce" ,
SchemaName : "server_nonce" ,
},
{
Name : "NewNonceHash2" ,
SchemaName : "new_nonce_hash2" ,
},
}
return typ
}
func (d *DhGenRetry ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dh_gen_retry#46dc1fb9 as nil" )
}
b .PutID (DhGenRetryTypeID )
return d .EncodeBare (b )
}
func (d *DhGenRetry ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dh_gen_retry#46dc1fb9 as nil" )
}
b .PutInt128 (d .Nonce )
b .PutInt128 (d .ServerNonce )
b .PutInt128 (d .NewNonceHash2 )
return nil
}
func (d *DhGenRetry ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dh_gen_retry#46dc1fb9 to nil" )
}
if err := b .ConsumeID (DhGenRetryTypeID ); err != nil {
return fmt .Errorf ("unable to decode dh_gen_retry#46dc1fb9: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DhGenRetry ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dh_gen_retry#46dc1fb9 to nil" )
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_retry#46dc1fb9: field nonce: %w" , err )
}
d .Nonce = value
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_retry#46dc1fb9: field server_nonce: %w" , err )
}
d .ServerNonce = value
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_retry#46dc1fb9: field new_nonce_hash2: %w" , err )
}
d .NewNonceHash2 = value
}
return nil
}
func (d *DhGenRetry ) GetNonce () (value bin .Int128 ) {
if d == nil {
return
}
return d .Nonce
}
func (d *DhGenRetry ) GetServerNonce () (value bin .Int128 ) {
if d == nil {
return
}
return d .ServerNonce
}
func (d *DhGenRetry ) GetNewNonceHash2 () (value bin .Int128 ) {
if d == nil {
return
}
return d .NewNonceHash2
}
type DhGenFail struct {
Nonce bin .Int128
ServerNonce bin .Int128
NewNonceHash3 bin .Int128
}
const DhGenFailTypeID = 0xa69dae02
func (d DhGenFail ) construct () SetClientDHParamsAnswerClass { return &d }
var (
_ bin .Encoder = &DhGenFail {}
_ bin .Decoder = &DhGenFail {}
_ bin .BareEncoder = &DhGenFail {}
_ bin .BareDecoder = &DhGenFail {}
_ SetClientDHParamsAnswerClass = &DhGenFail {}
)
func (d *DhGenFail ) Zero () bool {
if d == nil {
return true
}
if !(d .Nonce == bin .Int128 {}) {
return false
}
if !(d .ServerNonce == bin .Int128 {}) {
return false
}
if !(d .NewNonceHash3 == bin .Int128 {}) {
return false
}
return true
}
func (d *DhGenFail ) String () string {
if d == nil {
return "DhGenFail(nil)"
}
type Alias DhGenFail
return fmt .Sprintf ("DhGenFail%+v" , Alias (*d ))
}
func (*DhGenFail ) TypeID () uint32 {
return DhGenFailTypeID
}
func (*DhGenFail ) TypeName () string {
return "dh_gen_fail"
}
func (d *DhGenFail ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "dh_gen_fail" ,
ID : DhGenFailTypeID ,
}
if d == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Nonce" ,
SchemaName : "nonce" ,
},
{
Name : "ServerNonce" ,
SchemaName : "server_nonce" ,
},
{
Name : "NewNonceHash3" ,
SchemaName : "new_nonce_hash3" ,
},
}
return typ
}
func (d *DhGenFail ) Encode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dh_gen_fail#a69dae02 as nil" )
}
b .PutID (DhGenFailTypeID )
return d .EncodeBare (b )
}
func (d *DhGenFail ) EncodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't encode dh_gen_fail#a69dae02 as nil" )
}
b .PutInt128 (d .Nonce )
b .PutInt128 (d .ServerNonce )
b .PutInt128 (d .NewNonceHash3 )
return nil
}
func (d *DhGenFail ) Decode (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dh_gen_fail#a69dae02 to nil" )
}
if err := b .ConsumeID (DhGenFailTypeID ); err != nil {
return fmt .Errorf ("unable to decode dh_gen_fail#a69dae02: %w" , err )
}
return d .DecodeBare (b )
}
func (d *DhGenFail ) DecodeBare (b *bin .Buffer ) error {
if d == nil {
return fmt .Errorf ("can't decode dh_gen_fail#a69dae02 to nil" )
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_fail#a69dae02: field nonce: %w" , err )
}
d .Nonce = value
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_fail#a69dae02: field server_nonce: %w" , err )
}
d .ServerNonce = value
}
{
value , err := b .Int128 ()
if err != nil {
return fmt .Errorf ("unable to decode dh_gen_fail#a69dae02: field new_nonce_hash3: %w" , err )
}
d .NewNonceHash3 = value
}
return nil
}
func (d *DhGenFail ) GetNonce () (value bin .Int128 ) {
if d == nil {
return
}
return d .Nonce
}
func (d *DhGenFail ) GetServerNonce () (value bin .Int128 ) {
if d == nil {
return
}
return d .ServerNonce
}
func (d *DhGenFail ) GetNewNonceHash3 () (value bin .Int128 ) {
if d == nil {
return
}
return d .NewNonceHash3
}
const SetClientDHParamsAnswerClassName = "Set_client_DH_params_answer"
type SetClientDHParamsAnswerClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () SetClientDHParamsAnswerClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetNonce () (value bin .Int128 )
GetServerNonce () (value bin .Int128 )
}
func DecodeSetClientDHParamsAnswer (buf *bin .Buffer ) (SetClientDHParamsAnswerClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case DhGenOkTypeID :
v := DhGenOk {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SetClientDHParamsAnswerClass: %w" , err )
}
return &v , nil
case DhGenRetryTypeID :
v := DhGenRetry {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SetClientDHParamsAnswerClass: %w" , err )
}
return &v , nil
case DhGenFailTypeID :
v := DhGenFail {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode SetClientDHParamsAnswerClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode SetClientDHParamsAnswerClass: %w" , bin .NewUnexpectedID (id ))
}
}
type SetClientDHParamsAnswerBox struct {
Set_client_DH_params_answer SetClientDHParamsAnswerClass
}
func (b *SetClientDHParamsAnswerBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode SetClientDHParamsAnswerBox to nil" )
}
v , err := DecodeSetClientDHParamsAnswer (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .Set_client_DH_params_answer = v
return nil
}
func (b *SetClientDHParamsAnswerBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .Set_client_DH_params_answer == nil {
return fmt .Errorf ("unable to encode SetClientDHParamsAnswerClass as nil" )
}
return b .Set_client_DH_params_answer .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 .