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 PhotoSizeEmpty struct {
Type string
}
const PhotoSizeEmptyTypeID = 0xe17e23c
func (p PhotoSizeEmpty ) construct () PhotoSizeClass { return &p }
var (
_ bin .Encoder = &PhotoSizeEmpty {}
_ bin .Decoder = &PhotoSizeEmpty {}
_ bin .BareEncoder = &PhotoSizeEmpty {}
_ bin .BareDecoder = &PhotoSizeEmpty {}
_ PhotoSizeClass = &PhotoSizeEmpty {}
)
func (p *PhotoSizeEmpty ) Zero () bool {
if p == nil {
return true
}
if !(p .Type == "" ) {
return false
}
return true
}
func (p *PhotoSizeEmpty ) String () string {
if p == nil {
return "PhotoSizeEmpty(nil)"
}
type Alias PhotoSizeEmpty
return fmt .Sprintf ("PhotoSizeEmpty%+v" , Alias (*p ))
}
func (p *PhotoSizeEmpty ) FillFrom (from interface {
GetType () (value string )
}) {
p .Type = from .GetType ()
}
func (*PhotoSizeEmpty ) TypeID () uint32 {
return PhotoSizeEmptyTypeID
}
func (*PhotoSizeEmpty ) TypeName () string {
return "photoSizeEmpty"
}
func (p *PhotoSizeEmpty ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photoSizeEmpty" ,
ID : PhotoSizeEmptyTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
}
return typ
}
func (p *PhotoSizeEmpty ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoSizeEmpty#e17e23c as nil" )
}
b .PutID (PhotoSizeEmptyTypeID )
return p .EncodeBare (b )
}
func (p *PhotoSizeEmpty ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoSizeEmpty#e17e23c as nil" )
}
b .PutString (p .Type )
return nil
}
func (p *PhotoSizeEmpty ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoSizeEmpty#e17e23c to nil" )
}
if err := b .ConsumeID (PhotoSizeEmptyTypeID ); err != nil {
return fmt .Errorf ("unable to decode photoSizeEmpty#e17e23c: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotoSizeEmpty ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoSizeEmpty#e17e23c to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode photoSizeEmpty#e17e23c: field type: %w" , err )
}
p .Type = value
}
return nil
}
func (p *PhotoSizeEmpty ) GetType () (value string ) {
if p == nil {
return
}
return p .Type
}
type PhotoSize struct {
Type string
W int
H int
Size int
}
const PhotoSizeTypeID = 0x75c78e60
func (p PhotoSize ) construct () PhotoSizeClass { return &p }
var (
_ bin .Encoder = &PhotoSize {}
_ bin .Decoder = &PhotoSize {}
_ bin .BareEncoder = &PhotoSize {}
_ bin .BareDecoder = &PhotoSize {}
_ PhotoSizeClass = &PhotoSize {}
)
func (p *PhotoSize ) Zero () bool {
if p == nil {
return true
}
if !(p .Type == "" ) {
return false
}
if !(p .W == 0 ) {
return false
}
if !(p .H == 0 ) {
return false
}
if !(p .Size == 0 ) {
return false
}
return true
}
func (p *PhotoSize ) String () string {
if p == nil {
return "PhotoSize(nil)"
}
type Alias PhotoSize
return fmt .Sprintf ("PhotoSize%+v" , Alias (*p ))
}
func (p *PhotoSize ) FillFrom (from interface {
GetType () (value string )
GetW () (value int )
GetH () (value int )
GetSize () (value int )
}) {
p .Type = from .GetType ()
p .W = from .GetW ()
p .H = from .GetH ()
p .Size = from .GetSize ()
}
func (*PhotoSize ) TypeID () uint32 {
return PhotoSizeTypeID
}
func (*PhotoSize ) TypeName () string {
return "photoSize"
}
func (p *PhotoSize ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photoSize" ,
ID : PhotoSizeTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "W" ,
SchemaName : "w" ,
},
{
Name : "H" ,
SchemaName : "h" ,
},
{
Name : "Size" ,
SchemaName : "size" ,
},
}
return typ
}
func (p *PhotoSize ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoSize#75c78e60 as nil" )
}
b .PutID (PhotoSizeTypeID )
return p .EncodeBare (b )
}
func (p *PhotoSize ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoSize#75c78e60 as nil" )
}
b .PutString (p .Type )
b .PutInt (p .W )
b .PutInt (p .H )
b .PutInt (p .Size )
return nil
}
func (p *PhotoSize ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoSize#75c78e60 to nil" )
}
if err := b .ConsumeID (PhotoSizeTypeID ); err != nil {
return fmt .Errorf ("unable to decode photoSize#75c78e60: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotoSize ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoSize#75c78e60 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode photoSize#75c78e60: field type: %w" , err )
}
p .Type = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoSize#75c78e60: field w: %w" , err )
}
p .W = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoSize#75c78e60: field h: %w" , err )
}
p .H = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoSize#75c78e60: field size: %w" , err )
}
p .Size = value
}
return nil
}
func (p *PhotoSize ) GetType () (value string ) {
if p == nil {
return
}
return p .Type
}
func (p *PhotoSize ) GetW () (value int ) {
if p == nil {
return
}
return p .W
}
func (p *PhotoSize ) GetH () (value int ) {
if p == nil {
return
}
return p .H
}
func (p *PhotoSize ) GetSize () (value int ) {
if p == nil {
return
}
return p .Size
}
type PhotoCachedSize struct {
Type string
W int
H int
Bytes []byte
}
const PhotoCachedSizeTypeID = 0x21e1ad6
func (p PhotoCachedSize ) construct () PhotoSizeClass { return &p }
var (
_ bin .Encoder = &PhotoCachedSize {}
_ bin .Decoder = &PhotoCachedSize {}
_ bin .BareEncoder = &PhotoCachedSize {}
_ bin .BareDecoder = &PhotoCachedSize {}
_ PhotoSizeClass = &PhotoCachedSize {}
)
func (p *PhotoCachedSize ) Zero () bool {
if p == nil {
return true
}
if !(p .Type == "" ) {
return false
}
if !(p .W == 0 ) {
return false
}
if !(p .H == 0 ) {
return false
}
if !(p .Bytes == nil ) {
return false
}
return true
}
func (p *PhotoCachedSize ) String () string {
if p == nil {
return "PhotoCachedSize(nil)"
}
type Alias PhotoCachedSize
return fmt .Sprintf ("PhotoCachedSize%+v" , Alias (*p ))
}
func (p *PhotoCachedSize ) FillFrom (from interface {
GetType () (value string )
GetW () (value int )
GetH () (value int )
GetBytes () (value []byte )
}) {
p .Type = from .GetType ()
p .W = from .GetW ()
p .H = from .GetH ()
p .Bytes = from .GetBytes ()
}
func (*PhotoCachedSize ) TypeID () uint32 {
return PhotoCachedSizeTypeID
}
func (*PhotoCachedSize ) TypeName () string {
return "photoCachedSize"
}
func (p *PhotoCachedSize ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photoCachedSize" ,
ID : PhotoCachedSizeTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "W" ,
SchemaName : "w" ,
},
{
Name : "H" ,
SchemaName : "h" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
}
return typ
}
func (p *PhotoCachedSize ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoCachedSize#21e1ad6 as nil" )
}
b .PutID (PhotoCachedSizeTypeID )
return p .EncodeBare (b )
}
func (p *PhotoCachedSize ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoCachedSize#21e1ad6 as nil" )
}
b .PutString (p .Type )
b .PutInt (p .W )
b .PutInt (p .H )
b .PutBytes (p .Bytes )
return nil
}
func (p *PhotoCachedSize ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoCachedSize#21e1ad6 to nil" )
}
if err := b .ConsumeID (PhotoCachedSizeTypeID ); err != nil {
return fmt .Errorf ("unable to decode photoCachedSize#21e1ad6: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotoCachedSize ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoCachedSize#21e1ad6 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode photoCachedSize#21e1ad6: field type: %w" , err )
}
p .Type = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoCachedSize#21e1ad6: field w: %w" , err )
}
p .W = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoCachedSize#21e1ad6: field h: %w" , err )
}
p .H = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode photoCachedSize#21e1ad6: field bytes: %w" , err )
}
p .Bytes = value
}
return nil
}
func (p *PhotoCachedSize ) GetType () (value string ) {
if p == nil {
return
}
return p .Type
}
func (p *PhotoCachedSize ) GetW () (value int ) {
if p == nil {
return
}
return p .W
}
func (p *PhotoCachedSize ) GetH () (value int ) {
if p == nil {
return
}
return p .H
}
func (p *PhotoCachedSize ) GetBytes () (value []byte ) {
if p == nil {
return
}
return p .Bytes
}
type PhotoStrippedSize struct {
Type string
Bytes []byte
}
const PhotoStrippedSizeTypeID = 0xe0b0bc2e
func (p PhotoStrippedSize ) construct () PhotoSizeClass { return &p }
var (
_ bin .Encoder = &PhotoStrippedSize {}
_ bin .Decoder = &PhotoStrippedSize {}
_ bin .BareEncoder = &PhotoStrippedSize {}
_ bin .BareDecoder = &PhotoStrippedSize {}
_ PhotoSizeClass = &PhotoStrippedSize {}
)
func (p *PhotoStrippedSize ) Zero () bool {
if p == nil {
return true
}
if !(p .Type == "" ) {
return false
}
if !(p .Bytes == nil ) {
return false
}
return true
}
func (p *PhotoStrippedSize ) String () string {
if p == nil {
return "PhotoStrippedSize(nil)"
}
type Alias PhotoStrippedSize
return fmt .Sprintf ("PhotoStrippedSize%+v" , Alias (*p ))
}
func (p *PhotoStrippedSize ) FillFrom (from interface {
GetType () (value string )
GetBytes () (value []byte )
}) {
p .Type = from .GetType ()
p .Bytes = from .GetBytes ()
}
func (*PhotoStrippedSize ) TypeID () uint32 {
return PhotoStrippedSizeTypeID
}
func (*PhotoStrippedSize ) TypeName () string {
return "photoStrippedSize"
}
func (p *PhotoStrippedSize ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photoStrippedSize" ,
ID : PhotoStrippedSizeTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
}
return typ
}
func (p *PhotoStrippedSize ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoStrippedSize#e0b0bc2e as nil" )
}
b .PutID (PhotoStrippedSizeTypeID )
return p .EncodeBare (b )
}
func (p *PhotoStrippedSize ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoStrippedSize#e0b0bc2e as nil" )
}
b .PutString (p .Type )
b .PutBytes (p .Bytes )
return nil
}
func (p *PhotoStrippedSize ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoStrippedSize#e0b0bc2e to nil" )
}
if err := b .ConsumeID (PhotoStrippedSizeTypeID ); err != nil {
return fmt .Errorf ("unable to decode photoStrippedSize#e0b0bc2e: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotoStrippedSize ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoStrippedSize#e0b0bc2e to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode photoStrippedSize#e0b0bc2e: field type: %w" , err )
}
p .Type = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode photoStrippedSize#e0b0bc2e: field bytes: %w" , err )
}
p .Bytes = value
}
return nil
}
func (p *PhotoStrippedSize ) GetType () (value string ) {
if p == nil {
return
}
return p .Type
}
func (p *PhotoStrippedSize ) GetBytes () (value []byte ) {
if p == nil {
return
}
return p .Bytes
}
type PhotoSizeProgressive struct {
Type string
W int
H int
Sizes []int
}
const PhotoSizeProgressiveTypeID = 0xfa3efb95
func (p PhotoSizeProgressive ) construct () PhotoSizeClass { return &p }
var (
_ bin .Encoder = &PhotoSizeProgressive {}
_ bin .Decoder = &PhotoSizeProgressive {}
_ bin .BareEncoder = &PhotoSizeProgressive {}
_ bin .BareDecoder = &PhotoSizeProgressive {}
_ PhotoSizeClass = &PhotoSizeProgressive {}
)
func (p *PhotoSizeProgressive ) Zero () bool {
if p == nil {
return true
}
if !(p .Type == "" ) {
return false
}
if !(p .W == 0 ) {
return false
}
if !(p .H == 0 ) {
return false
}
if !(p .Sizes == nil ) {
return false
}
return true
}
func (p *PhotoSizeProgressive ) String () string {
if p == nil {
return "PhotoSizeProgressive(nil)"
}
type Alias PhotoSizeProgressive
return fmt .Sprintf ("PhotoSizeProgressive%+v" , Alias (*p ))
}
func (p *PhotoSizeProgressive ) FillFrom (from interface {
GetType () (value string )
GetW () (value int )
GetH () (value int )
GetSizes () (value []int )
}) {
p .Type = from .GetType ()
p .W = from .GetW ()
p .H = from .GetH ()
p .Sizes = from .GetSizes ()
}
func (*PhotoSizeProgressive ) TypeID () uint32 {
return PhotoSizeProgressiveTypeID
}
func (*PhotoSizeProgressive ) TypeName () string {
return "photoSizeProgressive"
}
func (p *PhotoSizeProgressive ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photoSizeProgressive" ,
ID : PhotoSizeProgressiveTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "W" ,
SchemaName : "w" ,
},
{
Name : "H" ,
SchemaName : "h" ,
},
{
Name : "Sizes" ,
SchemaName : "sizes" ,
},
}
return typ
}
func (p *PhotoSizeProgressive ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoSizeProgressive#fa3efb95 as nil" )
}
b .PutID (PhotoSizeProgressiveTypeID )
return p .EncodeBare (b )
}
func (p *PhotoSizeProgressive ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoSizeProgressive#fa3efb95 as nil" )
}
b .PutString (p .Type )
b .PutInt (p .W )
b .PutInt (p .H )
b .PutVectorHeader (len (p .Sizes ))
for _ , v := range p .Sizes {
b .PutInt (v )
}
return nil
}
func (p *PhotoSizeProgressive ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoSizeProgressive#fa3efb95 to nil" )
}
if err := b .ConsumeID (PhotoSizeProgressiveTypeID ); err != nil {
return fmt .Errorf ("unable to decode photoSizeProgressive#fa3efb95: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotoSizeProgressive ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoSizeProgressive#fa3efb95 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode photoSizeProgressive#fa3efb95: field type: %w" , err )
}
p .Type = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoSizeProgressive#fa3efb95: field w: %w" , err )
}
p .W = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoSizeProgressive#fa3efb95: field h: %w" , err )
}
p .H = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode photoSizeProgressive#fa3efb95: field sizes: %w" , err )
}
if headerLen > 0 {
p .Sizes = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode photoSizeProgressive#fa3efb95: field sizes: %w" , err )
}
p .Sizes = append (p .Sizes , value )
}
}
return nil
}
func (p *PhotoSizeProgressive ) GetType () (value string ) {
if p == nil {
return
}
return p .Type
}
func (p *PhotoSizeProgressive ) GetW () (value int ) {
if p == nil {
return
}
return p .W
}
func (p *PhotoSizeProgressive ) GetH () (value int ) {
if p == nil {
return
}
return p .H
}
func (p *PhotoSizeProgressive ) GetSizes () (value []int ) {
if p == nil {
return
}
return p .Sizes
}
type PhotoPathSize struct {
Type string
Bytes []byte
}
const PhotoPathSizeTypeID = 0xd8214d41
func (p PhotoPathSize ) construct () PhotoSizeClass { return &p }
var (
_ bin .Encoder = &PhotoPathSize {}
_ bin .Decoder = &PhotoPathSize {}
_ bin .BareEncoder = &PhotoPathSize {}
_ bin .BareDecoder = &PhotoPathSize {}
_ PhotoSizeClass = &PhotoPathSize {}
)
func (p *PhotoPathSize ) Zero () bool {
if p == nil {
return true
}
if !(p .Type == "" ) {
return false
}
if !(p .Bytes == nil ) {
return false
}
return true
}
func (p *PhotoPathSize ) String () string {
if p == nil {
return "PhotoPathSize(nil)"
}
type Alias PhotoPathSize
return fmt .Sprintf ("PhotoPathSize%+v" , Alias (*p ))
}
func (p *PhotoPathSize ) FillFrom (from interface {
GetType () (value string )
GetBytes () (value []byte )
}) {
p .Type = from .GetType ()
p .Bytes = from .GetBytes ()
}
func (*PhotoPathSize ) TypeID () uint32 {
return PhotoPathSizeTypeID
}
func (*PhotoPathSize ) TypeName () string {
return "photoPathSize"
}
func (p *PhotoPathSize ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "photoPathSize" ,
ID : PhotoPathSizeTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "Bytes" ,
SchemaName : "bytes" ,
},
}
return typ
}
func (p *PhotoPathSize ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoPathSize#d8214d41 as nil" )
}
b .PutID (PhotoPathSizeTypeID )
return p .EncodeBare (b )
}
func (p *PhotoPathSize ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode photoPathSize#d8214d41 as nil" )
}
b .PutString (p .Type )
b .PutBytes (p .Bytes )
return nil
}
func (p *PhotoPathSize ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoPathSize#d8214d41 to nil" )
}
if err := b .ConsumeID (PhotoPathSizeTypeID ); err != nil {
return fmt .Errorf ("unable to decode photoPathSize#d8214d41: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PhotoPathSize ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode photoPathSize#d8214d41 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode photoPathSize#d8214d41: field type: %w" , err )
}
p .Type = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode photoPathSize#d8214d41: field bytes: %w" , err )
}
p .Bytes = value
}
return nil
}
func (p *PhotoPathSize ) GetType () (value string ) {
if p == nil {
return
}
return p .Type
}
func (p *PhotoPathSize ) GetBytes () (value []byte ) {
if p == nil {
return
}
return p .Bytes
}
const PhotoSizeClassName = "PhotoSize"
type PhotoSizeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PhotoSizeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetType () (value string )
AsNotEmpty () (NotEmptyPhotoSize , bool )
}
type NotEmptyPhotoSize interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PhotoSizeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetType () (value string )
}
func (p *PhotoSizeEmpty ) AsNotEmpty () (NotEmptyPhotoSize , bool ) {
value , ok := (PhotoSizeClass (p )).(NotEmptyPhotoSize )
return value , ok
}
func (p *PhotoSize ) AsNotEmpty () (NotEmptyPhotoSize , bool ) {
value , ok := (PhotoSizeClass (p )).(NotEmptyPhotoSize )
return value , ok
}
func (p *PhotoCachedSize ) AsNotEmpty () (NotEmptyPhotoSize , bool ) {
value , ok := (PhotoSizeClass (p )).(NotEmptyPhotoSize )
return value , ok
}
func (p *PhotoStrippedSize ) AsNotEmpty () (NotEmptyPhotoSize , bool ) {
value , ok := (PhotoSizeClass (p )).(NotEmptyPhotoSize )
return value , ok
}
func (p *PhotoSizeProgressive ) AsNotEmpty () (NotEmptyPhotoSize , bool ) {
value , ok := (PhotoSizeClass (p )).(NotEmptyPhotoSize )
return value , ok
}
func (p *PhotoPathSize ) AsNotEmpty () (NotEmptyPhotoSize , bool ) {
value , ok := (PhotoSizeClass (p )).(NotEmptyPhotoSize )
return value , ok
}
func DecodePhotoSize (buf *bin .Buffer ) (PhotoSizeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PhotoSizeEmptyTypeID :
v := PhotoSizeEmpty {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotoSizeClass: %w" , err )
}
return &v , nil
case PhotoSizeTypeID :
v := PhotoSize {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotoSizeClass: %w" , err )
}
return &v , nil
case PhotoCachedSizeTypeID :
v := PhotoCachedSize {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotoSizeClass: %w" , err )
}
return &v , nil
case PhotoStrippedSizeTypeID :
v := PhotoStrippedSize {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotoSizeClass: %w" , err )
}
return &v , nil
case PhotoSizeProgressiveTypeID :
v := PhotoSizeProgressive {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotoSizeClass: %w" , err )
}
return &v , nil
case PhotoPathSizeTypeID :
v := PhotoPathSize {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PhotoSizeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PhotoSizeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PhotoSizeBox struct {
PhotoSize PhotoSizeClass
}
func (b *PhotoSizeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PhotoSizeBox to nil" )
}
v , err := DecodePhotoSize (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .PhotoSize = v
return nil
}
func (b *PhotoSizeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .PhotoSize == nil {
return fmt .Errorf ("unable to encode PhotoSizeClass as nil" )
}
return b .PhotoSize .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 .