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 UserProfilePhotoEmpty struct {
}
const UserProfilePhotoEmptyTypeID = 0x4f11bae1
func (u UserProfilePhotoEmpty ) construct () UserProfilePhotoClass { return &u }
var (
_ bin .Encoder = &UserProfilePhotoEmpty {}
_ bin .Decoder = &UserProfilePhotoEmpty {}
_ bin .BareEncoder = &UserProfilePhotoEmpty {}
_ bin .BareDecoder = &UserProfilePhotoEmpty {}
_ UserProfilePhotoClass = &UserProfilePhotoEmpty {}
)
func (u *UserProfilePhotoEmpty ) Zero () bool {
if u == nil {
return true
}
return true
}
func (u *UserProfilePhotoEmpty ) String () string {
if u == nil {
return "UserProfilePhotoEmpty(nil)"
}
type Alias UserProfilePhotoEmpty
return fmt .Sprintf ("UserProfilePhotoEmpty%+v" , Alias (*u ))
}
func (*UserProfilePhotoEmpty ) TypeID () uint32 {
return UserProfilePhotoEmptyTypeID
}
func (*UserProfilePhotoEmpty ) TypeName () string {
return "userProfilePhotoEmpty"
}
func (u *UserProfilePhotoEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "userProfilePhotoEmpty" ,
ID : UserProfilePhotoEmptyTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (u *UserProfilePhotoEmpty ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userProfilePhotoEmpty#4f11bae1 as nil" )
}
b .PutID (UserProfilePhotoEmptyTypeID )
return u .EncodeBare (b )
}
func (u *UserProfilePhotoEmpty ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userProfilePhotoEmpty#4f11bae1 as nil" )
}
return nil
}
func (u *UserProfilePhotoEmpty ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userProfilePhotoEmpty#4f11bae1 to nil" )
}
if err := b .ConsumeID (UserProfilePhotoEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode userProfilePhotoEmpty#4f11bae1: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserProfilePhotoEmpty ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userProfilePhotoEmpty#4f11bae1 to nil" )
}
return nil
}
type UserProfilePhoto struct {
Flags bin .Fields
HasVideo bool
Personal bool
PhotoID int64
StrippedThumb []byte
DCID int
}
const UserProfilePhotoTypeID = 0x82d1f706
func (u UserProfilePhoto ) construct () UserProfilePhotoClass { return &u }
var (
_ bin .Encoder = &UserProfilePhoto {}
_ bin .Decoder = &UserProfilePhoto {}
_ bin .BareEncoder = &UserProfilePhoto {}
_ bin .BareDecoder = &UserProfilePhoto {}
_ UserProfilePhotoClass = &UserProfilePhoto {}
)
func (u *UserProfilePhoto ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .HasVideo == false ) {
return false
}
if !(u .Personal == false ) {
return false
}
if !(u .PhotoID == 0 ) {
return false
}
if !(u .StrippedThumb == nil ) {
return false
}
if !(u .DCID == 0 ) {
return false
}
return true
}
func (u *UserProfilePhoto ) String () string {
if u == nil {
return "UserProfilePhoto(nil)"
}
type Alias UserProfilePhoto
return fmt .Sprintf ("UserProfilePhoto%+v" , Alias (*u ))
}
func (u *UserProfilePhoto ) FillFrom (from interface {
GetHasVideo () (value bool )
GetPersonal () (value bool )
GetPhotoID () (value int64 )
GetStrippedThumb () (value []byte , ok bool )
GetDCID () (value int )
}) {
u .HasVideo = from .GetHasVideo ()
u .Personal = from .GetPersonal ()
u .PhotoID = from .GetPhotoID ()
if val , ok := from .GetStrippedThumb (); ok {
u .StrippedThumb = val
}
u .DCID = from .GetDCID ()
}
func (*UserProfilePhoto ) TypeID () uint32 {
return UserProfilePhotoTypeID
}
func (*UserProfilePhoto ) TypeName () string {
return "userProfilePhoto"
}
func (u *UserProfilePhoto ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "userProfilePhoto" ,
ID : UserProfilePhotoTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "HasVideo" ,
SchemaName : "has_video" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "Personal" ,
SchemaName : "personal" ,
Null : !u .Flags .Has (2 ),
},
{
Name : "PhotoID" ,
SchemaName : "photo_id" ,
},
{
Name : "StrippedThumb" ,
SchemaName : "stripped_thumb" ,
Null : !u .Flags .Has (1 ),
},
{
Name : "DCID" ,
SchemaName : "dc_id" ,
},
}
return typ
}
func (u *UserProfilePhoto ) SetFlags () {
if !(u .HasVideo == false ) {
u .Flags .Set (0 )
}
if !(u .Personal == false ) {
u .Flags .Set (2 )
}
if !(u .StrippedThumb == nil ) {
u .Flags .Set (1 )
}
}
func (u *UserProfilePhoto ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userProfilePhoto#82d1f706 as nil" )
}
b .PutID (UserProfilePhotoTypeID )
return u .EncodeBare (b )
}
func (u *UserProfilePhoto ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode userProfilePhoto#82d1f706 as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode userProfilePhoto#82d1f706: field flags: %w" , err )
}
b .PutLong (u .PhotoID )
if u .Flags .Has (1 ) {
b .PutBytes (u .StrippedThumb )
}
b .PutInt (u .DCID )
return nil
}
func (u *UserProfilePhoto ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userProfilePhoto#82d1f706 to nil" )
}
if err := b .ConsumeID (UserProfilePhotoTypeID ); err != nil {
return fmt .Errorf ("unable to decode userProfilePhoto#82d1f706: %w" , err )
}
return u .DecodeBare (b )
}
func (u *UserProfilePhoto ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode userProfilePhoto#82d1f706 to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode userProfilePhoto#82d1f706: field flags: %w" , err )
}
}
u .HasVideo = u .Flags .Has (0 )
u .Personal = u .Flags .Has (2 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode userProfilePhoto#82d1f706: field photo_id: %w" , err )
}
u .PhotoID = value
}
if u .Flags .Has (1 ) {
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode userProfilePhoto#82d1f706: field stripped_thumb: %w" , err )
}
u .StrippedThumb = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode userProfilePhoto#82d1f706: field dc_id: %w" , err )
}
u .DCID = value
}
return nil
}
func (u *UserProfilePhoto ) SetHasVideo (value bool ) {
if value {
u .Flags .Set (0 )
u .HasVideo = true
} else {
u .Flags .Unset (0 )
u .HasVideo = false
}
}
func (u *UserProfilePhoto ) GetHasVideo () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (0 )
}
func (u *UserProfilePhoto ) SetPersonal (value bool ) {
if value {
u .Flags .Set (2 )
u .Personal = true
} else {
u .Flags .Unset (2 )
u .Personal = false
}
}
func (u *UserProfilePhoto ) GetPersonal () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (2 )
}
func (u *UserProfilePhoto ) GetPhotoID () (value int64 ) {
if u == nil {
return
}
return u .PhotoID
}
func (u *UserProfilePhoto ) SetStrippedThumb (value []byte ) {
u .Flags .Set (1 )
u .StrippedThumb = value
}
func (u *UserProfilePhoto ) GetStrippedThumb () (value []byte , ok bool ) {
if u == nil {
return
}
if !u .Flags .Has (1 ) {
return value , false
}
return u .StrippedThumb , true
}
func (u *UserProfilePhoto ) GetDCID () (value int ) {
if u == nil {
return
}
return u .DCID
}
const UserProfilePhotoClassName = "UserProfilePhoto"
type UserProfilePhotoClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () UserProfilePhotoClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
AsNotEmpty () (*UserProfilePhoto , bool )
}
func (u *UserProfilePhotoEmpty ) AsNotEmpty () (*UserProfilePhoto , bool ) {
return nil , false
}
func (u *UserProfilePhoto ) AsNotEmpty () (*UserProfilePhoto , bool ) {
return u , true
}
func DecodeUserProfilePhoto (buf *bin .Buffer ) (UserProfilePhotoClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case UserProfilePhotoEmptyTypeID :
v := UserProfilePhotoEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserProfilePhotoClass: %w" , err )
}
return &v , nil
case UserProfilePhotoTypeID :
v := UserProfilePhoto {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode UserProfilePhotoClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode UserProfilePhotoClass: %w" , bin .NewUnexpectedID (id ))
}
}
type UserProfilePhotoBox struct {
UserProfilePhoto UserProfilePhotoClass
}
func (b *UserProfilePhotoBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode UserProfilePhotoBox to nil" )
}
v , err := DecodeUserProfilePhoto (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .UserProfilePhoto = v
return nil
}
func (b *UserProfilePhotoBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .UserProfilePhoto == nil {
return fmt .Errorf ("unable to encode UserProfilePhotoClass as nil" )
}
return b .UserProfilePhoto .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 .