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 AccountPasswordSettings struct {
Flags bin .Fields
Email string
SecureSettings SecureSecretSettings
}
const AccountPasswordSettingsTypeID = 0x9a5c33e5
var (
_ bin .Encoder = &AccountPasswordSettings {}
_ bin .Decoder = &AccountPasswordSettings {}
_ bin .BareEncoder = &AccountPasswordSettings {}
_ bin .BareDecoder = &AccountPasswordSettings {}
)
func (p *AccountPasswordSettings ) Zero () bool {
if p == nil {
return true
}
if !(p .Flags .Zero ()) {
return false
}
if !(p .Email == "" ) {
return false
}
if !(p .SecureSettings .Zero ()) {
return false
}
return true
}
func (p *AccountPasswordSettings ) String () string {
if p == nil {
return "AccountPasswordSettings(nil)"
}
type Alias AccountPasswordSettings
return fmt .Sprintf ("AccountPasswordSettings%+v" , Alias (*p ))
}
func (p *AccountPasswordSettings ) FillFrom (from interface {
GetEmail () (value string , ok bool )
GetSecureSettings () (value SecureSecretSettings , ok bool )
}) {
if val , ok := from .GetEmail (); ok {
p .Email = val
}
if val , ok := from .GetSecureSettings (); ok {
p .SecureSettings = val
}
}
func (*AccountPasswordSettings ) TypeID () uint32 {
return AccountPasswordSettingsTypeID
}
func (*AccountPasswordSettings ) TypeName () string {
return "account.passwordSettings"
}
func (p *AccountPasswordSettings ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.passwordSettings" ,
ID : AccountPasswordSettingsTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Email" ,
SchemaName : "email" ,
Null : !p .Flags .Has (0 ),
},
{
Name : "SecureSettings" ,
SchemaName : "secure_settings" ,
Null : !p .Flags .Has (1 ),
},
}
return typ
}
func (p *AccountPasswordSettings ) SetFlags () {
if !(p .Email == "" ) {
p .Flags .Set (0 )
}
if !(p .SecureSettings .Zero ()) {
p .Flags .Set (1 )
}
}
func (p *AccountPasswordSettings ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode account.passwordSettings#9a5c33e5 as nil" )
}
b .PutID (AccountPasswordSettingsTypeID )
return p .EncodeBare (b )
}
func (p *AccountPasswordSettings ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode account.passwordSettings#9a5c33e5 as nil" )
}
p .SetFlags ()
if err := p .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.passwordSettings#9a5c33e5: field flags: %w" , err )
}
if p .Flags .Has (0 ) {
b .PutString (p .Email )
}
if p .Flags .Has (1 ) {
if err := p .SecureSettings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.passwordSettings#9a5c33e5: field secure_settings: %w" , err )
}
}
return nil
}
func (p *AccountPasswordSettings ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode account.passwordSettings#9a5c33e5 to nil" )
}
if err := b .ConsumeID (AccountPasswordSettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.passwordSettings#9a5c33e5: %w" , err )
}
return p .DecodeBare (b )
}
func (p *AccountPasswordSettings ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode account.passwordSettings#9a5c33e5 to nil" )
}
{
if err := p .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.passwordSettings#9a5c33e5: field flags: %w" , err )
}
}
if p .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.passwordSettings#9a5c33e5: field email: %w" , err )
}
p .Email = value
}
if p .Flags .Has (1 ) {
if err := p .SecureSettings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.passwordSettings#9a5c33e5: field secure_settings: %w" , err )
}
}
return nil
}
func (p *AccountPasswordSettings ) SetEmail (value string ) {
p .Flags .Set (0 )
p .Email = value
}
func (p *AccountPasswordSettings ) GetEmail () (value string , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (0 ) {
return value , false
}
return p .Email , true
}
func (p *AccountPasswordSettings ) SetSecureSettings (value SecureSecretSettings ) {
p .Flags .Set (1 )
p .SecureSettings = value
}
func (p *AccountPasswordSettings ) GetSecureSettings () (value SecureSecretSettings , ok bool ) {
if p == nil {
return
}
if !p .Flags .Has (1 ) {
return value , false
}
return p .SecureSettings , true
}
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 .