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 AutoSaveSettings struct {
Flags bin .Fields
Photos bool
Videos bool
VideoMaxSize int64
}
const AutoSaveSettingsTypeID = 0xc84834ce
var (
_ bin .Encoder = &AutoSaveSettings {}
_ bin .Decoder = &AutoSaveSettings {}
_ bin .BareEncoder = &AutoSaveSettings {}
_ bin .BareDecoder = &AutoSaveSettings {}
)
func (a *AutoSaveSettings ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .Photos == false ) {
return false
}
if !(a .Videos == false ) {
return false
}
if !(a .VideoMaxSize == 0 ) {
return false
}
return true
}
func (a *AutoSaveSettings ) String () string {
if a == nil {
return "AutoSaveSettings(nil)"
}
type Alias AutoSaveSettings
return fmt .Sprintf ("AutoSaveSettings%+v" , Alias (*a ))
}
func (a *AutoSaveSettings ) FillFrom (from interface {
GetPhotos () (value bool )
GetVideos () (value bool )
GetVideoMaxSize () (value int64 , ok bool )
}) {
a .Photos = from .GetPhotos ()
a .Videos = from .GetVideos ()
if val , ok := from .GetVideoMaxSize (); ok {
a .VideoMaxSize = val
}
}
func (*AutoSaveSettings ) TypeID () uint32 {
return AutoSaveSettingsTypeID
}
func (*AutoSaveSettings ) TypeName () string {
return "autoSaveSettings"
}
func (a *AutoSaveSettings ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "autoSaveSettings" ,
ID : AutoSaveSettingsTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Photos" ,
SchemaName : "photos" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "Videos" ,
SchemaName : "videos" ,
Null : !a .Flags .Has (1 ),
},
{
Name : "VideoMaxSize" ,
SchemaName : "video_max_size" ,
Null : !a .Flags .Has (2 ),
},
}
return typ
}
func (a *AutoSaveSettings ) SetFlags () {
if !(a .Photos == false ) {
a .Flags .Set (0 )
}
if !(a .Videos == false ) {
a .Flags .Set (1 )
}
if !(a .VideoMaxSize == 0 ) {
a .Flags .Set (2 )
}
}
func (a *AutoSaveSettings ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode autoSaveSettings#c84834ce as nil" )
}
b .PutID (AutoSaveSettingsTypeID )
return a .EncodeBare (b )
}
func (a *AutoSaveSettings ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode autoSaveSettings#c84834ce as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode autoSaveSettings#c84834ce: field flags: %w" , err )
}
if a .Flags .Has (2 ) {
b .PutLong (a .VideoMaxSize )
}
return nil
}
func (a *AutoSaveSettings ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode autoSaveSettings#c84834ce to nil" )
}
if err := b .ConsumeID (AutoSaveSettingsTypeID ); err != nil {
return fmt .Errorf ("unable to decode autoSaveSettings#c84834ce: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AutoSaveSettings ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode autoSaveSettings#c84834ce to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode autoSaveSettings#c84834ce: field flags: %w" , err )
}
}
a .Photos = a .Flags .Has (0 )
a .Videos = a .Flags .Has (1 )
if a .Flags .Has (2 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode autoSaveSettings#c84834ce: field video_max_size: %w" , err )
}
a .VideoMaxSize = value
}
return nil
}
func (a *AutoSaveSettings ) SetPhotos (value bool ) {
if value {
a .Flags .Set (0 )
a .Photos = true
} else {
a .Flags .Unset (0 )
a .Photos = false
}
}
func (a *AutoSaveSettings ) GetPhotos () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (0 )
}
func (a *AutoSaveSettings ) SetVideos (value bool ) {
if value {
a .Flags .Set (1 )
a .Videos = true
} else {
a .Flags .Unset (1 )
a .Videos = false
}
}
func (a *AutoSaveSettings ) GetVideos () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (1 )
}
func (a *AutoSaveSettings ) SetVideoMaxSize (value int64 ) {
a .Flags .Set (2 )
a .VideoMaxSize = value
}
func (a *AutoSaveSettings ) GetVideoMaxSize () (value int64 , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (2 ) {
return value , false
}
return a .VideoMaxSize , 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 .