// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// DocumentAttributeImageSize represents TL type `documentAttributeImageSize#6c37c15c`.
// Defines the width and height of an image uploaded as document
//
// See https://core.telegram.org/constructor/documentAttributeImageSize for reference.
type DocumentAttributeImageSize struct {
	// Width of image
	W int
	// Height of image
	H int
}

// DocumentAttributeImageSizeTypeID is TL type id of DocumentAttributeImageSize.
const DocumentAttributeImageSizeTypeID = 0x6c37c15c

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeImageSize) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeImageSize.
var (
	_ bin.Encoder     = &DocumentAttributeImageSize{}
	_ bin.Decoder     = &DocumentAttributeImageSize{}
	_ bin.BareEncoder = &DocumentAttributeImageSize{}
	_ bin.BareDecoder = &DocumentAttributeImageSize{}

	_ DocumentAttributeClass = &DocumentAttributeImageSize{}
)

func ( *DocumentAttributeImageSize) () bool {
	if  == nil {
		return true
	}
	if !(.W == 0) {
		return false
	}
	if !(.H == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeImageSize) () string {
	if  == nil {
		return "DocumentAttributeImageSize(nil)"
	}
	type  DocumentAttributeImageSize
	return fmt.Sprintf("DocumentAttributeImageSize%+v", (*))
}

// FillFrom fills DocumentAttributeImageSize from given interface.
func ( *DocumentAttributeImageSize) ( interface {
	() ( int)
	() ( int)
}) {
	.W = .()
	.H = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeImageSize) () uint32 {
	return DocumentAttributeImageSizeTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeImageSize) () string {
	return "documentAttributeImageSize"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeImageSize) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeImageSize",
		ID:   DocumentAttributeImageSizeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "W",
			SchemaName: "w",
		},
		{
			Name:       "H",
			SchemaName: "h",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeImageSize) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeImageSize#6c37c15c as nil")
	}
	.PutID(DocumentAttributeImageSizeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeImageSize) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeImageSize#6c37c15c as nil")
	}
	.PutInt(.W)
	.PutInt(.H)
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeImageSize) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeImageSize#6c37c15c to nil")
	}
	if  := .ConsumeID(DocumentAttributeImageSizeTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeImageSize#6c37c15c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeImageSize) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeImageSize#6c37c15c to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeImageSize#6c37c15c: field w: %w", )
		}
		.W = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeImageSize#6c37c15c: field h: %w", )
		}
		.H = 
	}
	return nil
}

// GetW returns value of W field.
func ( *DocumentAttributeImageSize) () ( int) {
	if  == nil {
		return
	}
	return .W
}

// GetH returns value of H field.
func ( *DocumentAttributeImageSize) () ( int) {
	if  == nil {
		return
	}
	return .H
}

// DocumentAttributeAnimated represents TL type `documentAttributeAnimated#11b58939`.
// Defines an animated GIF
//
// See https://core.telegram.org/constructor/documentAttributeAnimated for reference.
type DocumentAttributeAnimated struct {
}

// DocumentAttributeAnimatedTypeID is TL type id of DocumentAttributeAnimated.
const DocumentAttributeAnimatedTypeID = 0x11b58939

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeAnimated) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeAnimated.
var (
	_ bin.Encoder     = &DocumentAttributeAnimated{}
	_ bin.Decoder     = &DocumentAttributeAnimated{}
	_ bin.BareEncoder = &DocumentAttributeAnimated{}
	_ bin.BareDecoder = &DocumentAttributeAnimated{}

	_ DocumentAttributeClass = &DocumentAttributeAnimated{}
)

func ( *DocumentAttributeAnimated) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeAnimated) () string {
	if  == nil {
		return "DocumentAttributeAnimated(nil)"
	}
	type  DocumentAttributeAnimated
	return fmt.Sprintf("DocumentAttributeAnimated%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeAnimated) () uint32 {
	return DocumentAttributeAnimatedTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeAnimated) () string {
	return "documentAttributeAnimated"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeAnimated) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeAnimated",
		ID:   DocumentAttributeAnimatedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeAnimated) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeAnimated#11b58939 as nil")
	}
	.PutID(DocumentAttributeAnimatedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeAnimated) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeAnimated#11b58939 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeAnimated) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeAnimated#11b58939 to nil")
	}
	if  := .ConsumeID(DocumentAttributeAnimatedTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeAnimated#11b58939: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeAnimated) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeAnimated#11b58939 to nil")
	}
	return nil
}

// DocumentAttributeSticker represents TL type `documentAttributeSticker#6319d612`.
// Defines a sticker
//
// See https://core.telegram.org/constructor/documentAttributeSticker for reference.
type DocumentAttributeSticker struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a mask sticker
	Mask bool
	// Alternative emoji representation of sticker
	Alt string
	// Associated stickerset
	Stickerset InputStickerSetClass
	// Mask coordinates (if this is a mask sticker, attached to a photo)
	//
	// Use SetMaskCoords and GetMaskCoords helpers.
	MaskCoords MaskCoords
}

// DocumentAttributeStickerTypeID is TL type id of DocumentAttributeSticker.
const DocumentAttributeStickerTypeID = 0x6319d612

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeSticker) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeSticker.
var (
	_ bin.Encoder     = &DocumentAttributeSticker{}
	_ bin.Decoder     = &DocumentAttributeSticker{}
	_ bin.BareEncoder = &DocumentAttributeSticker{}
	_ bin.BareDecoder = &DocumentAttributeSticker{}

	_ DocumentAttributeClass = &DocumentAttributeSticker{}
)

func ( *DocumentAttributeSticker) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Mask == false) {
		return false
	}
	if !(.Alt == "") {
		return false
	}
	if !(.Stickerset == nil) {
		return false
	}
	if !(.MaskCoords.Zero()) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeSticker) () string {
	if  == nil {
		return "DocumentAttributeSticker(nil)"
	}
	type  DocumentAttributeSticker
	return fmt.Sprintf("DocumentAttributeSticker%+v", (*))
}

// FillFrom fills DocumentAttributeSticker from given interface.
func ( *DocumentAttributeSticker) ( interface {
	() ( bool)
	() ( string)
	() ( InputStickerSetClass)
	() ( MaskCoords,  bool)
}) {
	.Mask = .()
	.Alt = .()
	.Stickerset = .()
	if ,  := .();  {
		.MaskCoords = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeSticker) () uint32 {
	return DocumentAttributeStickerTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeSticker) () string {
	return "documentAttributeSticker"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeSticker) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeSticker",
		ID:   DocumentAttributeStickerTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Mask",
			SchemaName: "mask",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Alt",
			SchemaName: "alt",
		},
		{
			Name:       "Stickerset",
			SchemaName: "stickerset",
		},
		{
			Name:       "MaskCoords",
			SchemaName: "mask_coords",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DocumentAttributeSticker) () {
	if !(.Mask == false) {
		.Flags.Set(1)
	}
	if !(.MaskCoords.Zero()) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeSticker) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeSticker#6319d612 as nil")
	}
	.PutID(DocumentAttributeStickerTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeSticker) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeSticker#6319d612 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode documentAttributeSticker#6319d612: field flags: %w", )
	}
	.PutString(.Alt)
	if .Stickerset == nil {
		return fmt.Errorf("unable to encode documentAttributeSticker#6319d612: field stickerset is nil")
	}
	if  := .Stickerset.Encode();  != nil {
		return fmt.Errorf("unable to encode documentAttributeSticker#6319d612: field stickerset: %w", )
	}
	if .Flags.Has(0) {
		if  := .MaskCoords.Encode();  != nil {
			return fmt.Errorf("unable to encode documentAttributeSticker#6319d612: field mask_coords: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeSticker) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeSticker#6319d612 to nil")
	}
	if  := .ConsumeID(DocumentAttributeStickerTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeSticker#6319d612: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeSticker) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeSticker#6319d612 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode documentAttributeSticker#6319d612: field flags: %w", )
		}
	}
	.Mask = .Flags.Has(1)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeSticker#6319d612: field alt: %w", )
		}
		.Alt = 
	}
	{
		,  := DecodeInputStickerSet()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeSticker#6319d612: field stickerset: %w", )
		}
		.Stickerset = 
	}
	if .Flags.Has(0) {
		if  := .MaskCoords.Decode();  != nil {
			return fmt.Errorf("unable to decode documentAttributeSticker#6319d612: field mask_coords: %w", )
		}
	}
	return nil
}

// SetMask sets value of Mask conditional field.
func ( *DocumentAttributeSticker) ( bool) {
	if  {
		.Flags.Set(1)
		.Mask = true
	} else {
		.Flags.Unset(1)
		.Mask = false
	}
}

// GetMask returns value of Mask conditional field.
func ( *DocumentAttributeSticker) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetAlt returns value of Alt field.
func ( *DocumentAttributeSticker) () ( string) {
	if  == nil {
		return
	}
	return .Alt
}

// GetStickerset returns value of Stickerset field.
func ( *DocumentAttributeSticker) () ( InputStickerSetClass) {
	if  == nil {
		return
	}
	return .Stickerset
}

// SetMaskCoords sets value of MaskCoords conditional field.
func ( *DocumentAttributeSticker) ( MaskCoords) {
	.Flags.Set(0)
	.MaskCoords = 
}

// GetMaskCoords returns value of MaskCoords conditional field and
// boolean which is true if field was set.
func ( *DocumentAttributeSticker) () ( MaskCoords,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .MaskCoords, true
}

// DocumentAttributeVideo represents TL type `documentAttributeVideo#d38ff1c2`.
// Defines a video
//
// See https://core.telegram.org/constructor/documentAttributeVideo for reference.
type DocumentAttributeVideo struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a round video
	RoundMessage bool
	// Whether the video supports streaming
	SupportsStreaming bool
	// Whether the specified document is a video file with no audio tracks (a GIF animation
	// (even as MPEG4), for example)
	Nosound bool
	// Duration in seconds
	Duration float64
	// Video width
	W int
	// Video height
	H int
	// Number of bytes to preload when preloading videos (particularly video stories¹).
	//
	// Links:
	//  1) https://core.telegram.org/api/stories
	//
	// Use SetPreloadPrefixSize and GetPreloadPrefixSize helpers.
	PreloadPrefixSize int
}

// DocumentAttributeVideoTypeID is TL type id of DocumentAttributeVideo.
const DocumentAttributeVideoTypeID = 0xd38ff1c2

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeVideo) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeVideo.
var (
	_ bin.Encoder     = &DocumentAttributeVideo{}
	_ bin.Decoder     = &DocumentAttributeVideo{}
	_ bin.BareEncoder = &DocumentAttributeVideo{}
	_ bin.BareDecoder = &DocumentAttributeVideo{}

	_ DocumentAttributeClass = &DocumentAttributeVideo{}
)

func ( *DocumentAttributeVideo) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.RoundMessage == false) {
		return false
	}
	if !(.SupportsStreaming == false) {
		return false
	}
	if !(.Nosound == false) {
		return false
	}
	if !(.Duration == 0) {
		return false
	}
	if !(.W == 0) {
		return false
	}
	if !(.H == 0) {
		return false
	}
	if !(.PreloadPrefixSize == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeVideo) () string {
	if  == nil {
		return "DocumentAttributeVideo(nil)"
	}
	type  DocumentAttributeVideo
	return fmt.Sprintf("DocumentAttributeVideo%+v", (*))
}

// FillFrom fills DocumentAttributeVideo from given interface.
func ( *DocumentAttributeVideo) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( float64)
	() ( int)
	() ( int)
	() ( int,  bool)
}) {
	.RoundMessage = .()
	.SupportsStreaming = .()
	.Nosound = .()
	.Duration = .()
	.W = .()
	.H = .()
	if ,  := .();  {
		.PreloadPrefixSize = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeVideo) () uint32 {
	return DocumentAttributeVideoTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeVideo) () string {
	return "documentAttributeVideo"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeVideo) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeVideo",
		ID:   DocumentAttributeVideoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "RoundMessage",
			SchemaName: "round_message",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SupportsStreaming",
			SchemaName: "supports_streaming",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Nosound",
			SchemaName: "nosound",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
		},
		{
			Name:       "W",
			SchemaName: "w",
		},
		{
			Name:       "H",
			SchemaName: "h",
		},
		{
			Name:       "PreloadPrefixSize",
			SchemaName: "preload_prefix_size",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DocumentAttributeVideo) () {
	if !(.RoundMessage == false) {
		.Flags.Set(0)
	}
	if !(.SupportsStreaming == false) {
		.Flags.Set(1)
	}
	if !(.Nosound == false) {
		.Flags.Set(3)
	}
	if !(.PreloadPrefixSize == 0) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeVideo#d38ff1c2 as nil")
	}
	.PutID(DocumentAttributeVideoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeVideo#d38ff1c2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode documentAttributeVideo#d38ff1c2: field flags: %w", )
	}
	.PutDouble(.Duration)
	.PutInt(.W)
	.PutInt(.H)
	if .Flags.Has(2) {
		.PutInt(.PreloadPrefixSize)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeVideo#d38ff1c2 to nil")
	}
	if  := .ConsumeID(DocumentAttributeVideoTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeVideo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeVideo#d38ff1c2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field flags: %w", )
		}
	}
	.RoundMessage = .Flags.Has(0)
	.SupportsStreaming = .Flags.Has(1)
	.Nosound = .Flags.Has(3)
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field duration: %w", )
		}
		.Duration = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field w: %w", )
		}
		.W = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field h: %w", )
		}
		.H = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeVideo#d38ff1c2: field preload_prefix_size: %w", )
		}
		.PreloadPrefixSize = 
	}
	return nil
}

// SetRoundMessage sets value of RoundMessage conditional field.
func ( *DocumentAttributeVideo) ( bool) {
	if  {
		.Flags.Set(0)
		.RoundMessage = true
	} else {
		.Flags.Unset(0)
		.RoundMessage = false
	}
}

// GetRoundMessage returns value of RoundMessage conditional field.
func ( *DocumentAttributeVideo) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetSupportsStreaming sets value of SupportsStreaming conditional field.
func ( *DocumentAttributeVideo) ( bool) {
	if  {
		.Flags.Set(1)
		.SupportsStreaming = true
	} else {
		.Flags.Unset(1)
		.SupportsStreaming = false
	}
}

// GetSupportsStreaming returns value of SupportsStreaming conditional field.
func ( *DocumentAttributeVideo) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetNosound sets value of Nosound conditional field.
func ( *DocumentAttributeVideo) ( bool) {
	if  {
		.Flags.Set(3)
		.Nosound = true
	} else {
		.Flags.Unset(3)
		.Nosound = false
	}
}

// GetNosound returns value of Nosound conditional field.
func ( *DocumentAttributeVideo) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// GetDuration returns value of Duration field.
func ( *DocumentAttributeVideo) () ( float64) {
	if  == nil {
		return
	}
	return .Duration
}

// GetW returns value of W field.
func ( *DocumentAttributeVideo) () ( int) {
	if  == nil {
		return
	}
	return .W
}

// GetH returns value of H field.
func ( *DocumentAttributeVideo) () ( int) {
	if  == nil {
		return
	}
	return .H
}

// SetPreloadPrefixSize sets value of PreloadPrefixSize conditional field.
func ( *DocumentAttributeVideo) ( int) {
	.Flags.Set(2)
	.PreloadPrefixSize = 
}

// GetPreloadPrefixSize returns value of PreloadPrefixSize conditional field and
// boolean which is true if field was set.
func ( *DocumentAttributeVideo) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .PreloadPrefixSize, true
}

// DocumentAttributeAudio represents TL type `documentAttributeAudio#9852f9c6`.
// Represents an audio file
//
// See https://core.telegram.org/constructor/documentAttributeAudio for reference.
type DocumentAttributeAudio struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a voice message
	Voice bool
	// Duration in seconds
	Duration int
	// Name of song
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// Performer
	//
	// Use SetPerformer and GetPerformer helpers.
	Performer string
	// Waveform: consists in a series of bitpacked 5-bit values. Example implementation:
	// android¹.
	//
	// Links:
	//  1) https://github.com/DrKLO/Telegram/blob/96dce2c9aabc33b87db61d830aa087b6b03fe397/TMessagesProj/jni/audio.c#L546
	//
	// Use SetWaveform and GetWaveform helpers.
	Waveform []byte
}

// DocumentAttributeAudioTypeID is TL type id of DocumentAttributeAudio.
const DocumentAttributeAudioTypeID = 0x9852f9c6

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeAudio) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeAudio.
var (
	_ bin.Encoder     = &DocumentAttributeAudio{}
	_ bin.Decoder     = &DocumentAttributeAudio{}
	_ bin.BareEncoder = &DocumentAttributeAudio{}
	_ bin.BareDecoder = &DocumentAttributeAudio{}

	_ DocumentAttributeClass = &DocumentAttributeAudio{}
)

func ( *DocumentAttributeAudio) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Voice == false) {
		return false
	}
	if !(.Duration == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Performer == "") {
		return false
	}
	if !(.Waveform == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeAudio) () string {
	if  == nil {
		return "DocumentAttributeAudio(nil)"
	}
	type  DocumentAttributeAudio
	return fmt.Sprintf("DocumentAttributeAudio%+v", (*))
}

// FillFrom fills DocumentAttributeAudio from given interface.
func ( *DocumentAttributeAudio) ( interface {
	() ( bool)
	() ( int)
	() ( string,  bool)
	() ( string,  bool)
	() ( []byte,  bool)
}) {
	.Voice = .()
	.Duration = .()
	if ,  := .();  {
		.Title = 
	}

	if ,  := .();  {
		.Performer = 
	}

	if ,  := .();  {
		.Waveform = 
	}

}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeAudio) () uint32 {
	return DocumentAttributeAudioTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeAudio) () string {
	return "documentAttributeAudio"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeAudio) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeAudio",
		ID:   DocumentAttributeAudioTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Voice",
			SchemaName: "voice",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Duration",
			SchemaName: "duration",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Performer",
			SchemaName: "performer",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Waveform",
			SchemaName: "waveform",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DocumentAttributeAudio) () {
	if !(.Voice == false) {
		.Flags.Set(10)
	}
	if !(.Title == "") {
		.Flags.Set(0)
	}
	if !(.Performer == "") {
		.Flags.Set(1)
	}
	if !(.Waveform == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeAudio) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeAudio#9852f9c6 as nil")
	}
	.PutID(DocumentAttributeAudioTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeAudio) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeAudio#9852f9c6 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode documentAttributeAudio#9852f9c6: field flags: %w", )
	}
	.PutInt(.Duration)
	if .Flags.Has(0) {
		.PutString(.Title)
	}
	if .Flags.Has(1) {
		.PutString(.Performer)
	}
	if .Flags.Has(2) {
		.PutBytes(.Waveform)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeAudio) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeAudio#9852f9c6 to nil")
	}
	if  := .ConsumeID(DocumentAttributeAudioTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeAudio#9852f9c6: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeAudio) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeAudio#9852f9c6 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode documentAttributeAudio#9852f9c6: field flags: %w", )
		}
	}
	.Voice = .Flags.Has(10)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeAudio#9852f9c6: field duration: %w", )
		}
		.Duration = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeAudio#9852f9c6: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeAudio#9852f9c6: field performer: %w", )
		}
		.Performer = 
	}
	if .Flags.Has(2) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeAudio#9852f9c6: field waveform: %w", )
		}
		.Waveform = 
	}
	return nil
}

// SetVoice sets value of Voice conditional field.
func ( *DocumentAttributeAudio) ( bool) {
	if  {
		.Flags.Set(10)
		.Voice = true
	} else {
		.Flags.Unset(10)
		.Voice = false
	}
}

// GetVoice returns value of Voice conditional field.
func ( *DocumentAttributeAudio) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(10)
}

// GetDuration returns value of Duration field.
func ( *DocumentAttributeAudio) () ( int) {
	if  == nil {
		return
	}
	return .Duration
}

// SetTitle sets value of Title conditional field.
func ( *DocumentAttributeAudio) ( string) {
	.Flags.Set(0)
	.Title = 
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func ( *DocumentAttributeAudio) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Title, true
}

// SetPerformer sets value of Performer conditional field.
func ( *DocumentAttributeAudio) ( string) {
	.Flags.Set(1)
	.Performer = 
}

// GetPerformer returns value of Performer conditional field and
// boolean which is true if field was set.
func ( *DocumentAttributeAudio) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Performer, true
}

// SetWaveform sets value of Waveform conditional field.
func ( *DocumentAttributeAudio) ( []byte) {
	.Flags.Set(2)
	.Waveform = 
}

// GetWaveform returns value of Waveform conditional field and
// boolean which is true if field was set.
func ( *DocumentAttributeAudio) () ( []byte,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Waveform, true
}

// DocumentAttributeFilename represents TL type `documentAttributeFilename#15590068`.
// A simple document with a file name
//
// See https://core.telegram.org/constructor/documentAttributeFilename for reference.
type DocumentAttributeFilename struct {
	// The file name
	FileName string
}

// DocumentAttributeFilenameTypeID is TL type id of DocumentAttributeFilename.
const DocumentAttributeFilenameTypeID = 0x15590068

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeFilename) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeFilename.
var (
	_ bin.Encoder     = &DocumentAttributeFilename{}
	_ bin.Decoder     = &DocumentAttributeFilename{}
	_ bin.BareEncoder = &DocumentAttributeFilename{}
	_ bin.BareDecoder = &DocumentAttributeFilename{}

	_ DocumentAttributeClass = &DocumentAttributeFilename{}
)

func ( *DocumentAttributeFilename) () bool {
	if  == nil {
		return true
	}
	if !(.FileName == "") {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeFilename) () string {
	if  == nil {
		return "DocumentAttributeFilename(nil)"
	}
	type  DocumentAttributeFilename
	return fmt.Sprintf("DocumentAttributeFilename%+v", (*))
}

// FillFrom fills DocumentAttributeFilename from given interface.
func ( *DocumentAttributeFilename) ( interface {
	() ( string)
}) {
	.FileName = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeFilename) () uint32 {
	return DocumentAttributeFilenameTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeFilename) () string {
	return "documentAttributeFilename"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeFilename) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeFilename",
		ID:   DocumentAttributeFilenameTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FileName",
			SchemaName: "file_name",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeFilename) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeFilename#15590068 as nil")
	}
	.PutID(DocumentAttributeFilenameTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeFilename) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeFilename#15590068 as nil")
	}
	.PutString(.FileName)
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeFilename) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeFilename#15590068 to nil")
	}
	if  := .ConsumeID(DocumentAttributeFilenameTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeFilename#15590068: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeFilename) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeFilename#15590068 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeFilename#15590068: field file_name: %w", )
		}
		.FileName = 
	}
	return nil
}

// GetFileName returns value of FileName field.
func ( *DocumentAttributeFilename) () ( string) {
	if  == nil {
		return
	}
	return .FileName
}

// DocumentAttributeHasStickers represents TL type `documentAttributeHasStickers#9801d2f7`.
// Whether the current document has stickers attached
//
// See https://core.telegram.org/constructor/documentAttributeHasStickers for reference.
type DocumentAttributeHasStickers struct {
}

// DocumentAttributeHasStickersTypeID is TL type id of DocumentAttributeHasStickers.
const DocumentAttributeHasStickersTypeID = 0x9801d2f7

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeHasStickers) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeHasStickers.
var (
	_ bin.Encoder     = &DocumentAttributeHasStickers{}
	_ bin.Decoder     = &DocumentAttributeHasStickers{}
	_ bin.BareEncoder = &DocumentAttributeHasStickers{}
	_ bin.BareDecoder = &DocumentAttributeHasStickers{}

	_ DocumentAttributeClass = &DocumentAttributeHasStickers{}
)

func ( *DocumentAttributeHasStickers) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeHasStickers) () string {
	if  == nil {
		return "DocumentAttributeHasStickers(nil)"
	}
	type  DocumentAttributeHasStickers
	return fmt.Sprintf("DocumentAttributeHasStickers%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeHasStickers) () uint32 {
	return DocumentAttributeHasStickersTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeHasStickers) () string {
	return "documentAttributeHasStickers"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeHasStickers) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeHasStickers",
		ID:   DocumentAttributeHasStickersTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeHasStickers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeHasStickers#9801d2f7 as nil")
	}
	.PutID(DocumentAttributeHasStickersTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeHasStickers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeHasStickers#9801d2f7 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeHasStickers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeHasStickers#9801d2f7 to nil")
	}
	if  := .ConsumeID(DocumentAttributeHasStickersTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeHasStickers#9801d2f7: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeHasStickers) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeHasStickers#9801d2f7 to nil")
	}
	return nil
}

// DocumentAttributeCustomEmoji represents TL type `documentAttributeCustomEmoji#fd149899`.
// Info about a custom emoji
//
// See https://core.telegram.org/constructor/documentAttributeCustomEmoji for reference.
type DocumentAttributeCustomEmoji struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this custom emoji can be sent by non-Premium users
	Free bool
	// Whether the color of this TGS custom emoji should be changed to the text color when
	// used in messages, the accent color if used as emoji status, white on chat photos, or
	// another appropriate color based on context.
	TextColor bool
	// The actual emoji
	Alt string
	// The emoji stickerset to which this emoji belongs.
	Stickerset InputStickerSetClass
}

// DocumentAttributeCustomEmojiTypeID is TL type id of DocumentAttributeCustomEmoji.
const DocumentAttributeCustomEmojiTypeID = 0xfd149899

// construct implements constructor of DocumentAttributeClass.
func ( DocumentAttributeCustomEmoji) () DocumentAttributeClass { return & }

// Ensuring interfaces in compile-time for DocumentAttributeCustomEmoji.
var (
	_ bin.Encoder     = &DocumentAttributeCustomEmoji{}
	_ bin.Decoder     = &DocumentAttributeCustomEmoji{}
	_ bin.BareEncoder = &DocumentAttributeCustomEmoji{}
	_ bin.BareDecoder = &DocumentAttributeCustomEmoji{}

	_ DocumentAttributeClass = &DocumentAttributeCustomEmoji{}
)

func ( *DocumentAttributeCustomEmoji) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Free == false) {
		return false
	}
	if !(.TextColor == false) {
		return false
	}
	if !(.Alt == "") {
		return false
	}
	if !(.Stickerset == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *DocumentAttributeCustomEmoji) () string {
	if  == nil {
		return "DocumentAttributeCustomEmoji(nil)"
	}
	type  DocumentAttributeCustomEmoji
	return fmt.Sprintf("DocumentAttributeCustomEmoji%+v", (*))
}

// FillFrom fills DocumentAttributeCustomEmoji from given interface.
func ( *DocumentAttributeCustomEmoji) ( interface {
	() ( bool)
	() ( bool)
	() ( string)
	() ( InputStickerSetClass)
}) {
	.Free = .()
	.TextColor = .()
	.Alt = .()
	.Stickerset = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*DocumentAttributeCustomEmoji) () uint32 {
	return DocumentAttributeCustomEmojiTypeID
}

// TypeName returns name of type in TL schema.
func (*DocumentAttributeCustomEmoji) () string {
	return "documentAttributeCustomEmoji"
}

// TypeInfo returns info about TL type.
func ( *DocumentAttributeCustomEmoji) () tdp.Type {
	 := tdp.Type{
		Name: "documentAttributeCustomEmoji",
		ID:   DocumentAttributeCustomEmojiTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Free",
			SchemaName: "free",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "TextColor",
			SchemaName: "text_color",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Alt",
			SchemaName: "alt",
		},
		{
			Name:       "Stickerset",
			SchemaName: "stickerset",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DocumentAttributeCustomEmoji) () {
	if !(.Free == false) {
		.Flags.Set(0)
	}
	if !(.TextColor == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *DocumentAttributeCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeCustomEmoji#fd149899 as nil")
	}
	.PutID(DocumentAttributeCustomEmojiTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DocumentAttributeCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode documentAttributeCustomEmoji#fd149899 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode documentAttributeCustomEmoji#fd149899: field flags: %w", )
	}
	.PutString(.Alt)
	if .Stickerset == nil {
		return fmt.Errorf("unable to encode documentAttributeCustomEmoji#fd149899: field stickerset is nil")
	}
	if  := .Stickerset.Encode();  != nil {
		return fmt.Errorf("unable to encode documentAttributeCustomEmoji#fd149899: field stickerset: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *DocumentAttributeCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeCustomEmoji#fd149899 to nil")
	}
	if  := .ConsumeID(DocumentAttributeCustomEmojiTypeID);  != nil {
		return fmt.Errorf("unable to decode documentAttributeCustomEmoji#fd149899: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DocumentAttributeCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode documentAttributeCustomEmoji#fd149899 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode documentAttributeCustomEmoji#fd149899: field flags: %w", )
		}
	}
	.Free = .Flags.Has(0)
	.TextColor = .Flags.Has(1)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeCustomEmoji#fd149899: field alt: %w", )
		}
		.Alt = 
	}
	{
		,  := DecodeInputStickerSet()
		if  != nil {
			return fmt.Errorf("unable to decode documentAttributeCustomEmoji#fd149899: field stickerset: %w", )
		}
		.Stickerset = 
	}
	return nil
}

// SetFree sets value of Free conditional field.
func ( *DocumentAttributeCustomEmoji) ( bool) {
	if  {
		.Flags.Set(0)
		.Free = true
	} else {
		.Flags.Unset(0)
		.Free = false
	}
}

// GetFree returns value of Free conditional field.
func ( *DocumentAttributeCustomEmoji) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetTextColor sets value of TextColor conditional field.
func ( *DocumentAttributeCustomEmoji) ( bool) {
	if  {
		.Flags.Set(1)
		.TextColor = true
	} else {
		.Flags.Unset(1)
		.TextColor = false
	}
}

// GetTextColor returns value of TextColor conditional field.
func ( *DocumentAttributeCustomEmoji) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetAlt returns value of Alt field.
func ( *DocumentAttributeCustomEmoji) () ( string) {
	if  == nil {
		return
	}
	return .Alt
}

// GetStickerset returns value of Stickerset field.
func ( *DocumentAttributeCustomEmoji) () ( InputStickerSetClass) {
	if  == nil {
		return
	}
	return .Stickerset
}

// DocumentAttributeClassName is schema name of DocumentAttributeClass.
const DocumentAttributeClassName = "DocumentAttribute"

// DocumentAttributeClass represents DocumentAttribute generic type.
//
// See https://core.telegram.org/type/DocumentAttribute for reference.
//
// Example:
//
//	g, err := tg.DecodeDocumentAttribute(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.DocumentAttributeImageSize: // documentAttributeImageSize#6c37c15c
//	case *tg.DocumentAttributeAnimated: // documentAttributeAnimated#11b58939
//	case *tg.DocumentAttributeSticker: // documentAttributeSticker#6319d612
//	case *tg.DocumentAttributeVideo: // documentAttributeVideo#d38ff1c2
//	case *tg.DocumentAttributeAudio: // documentAttributeAudio#9852f9c6
//	case *tg.DocumentAttributeFilename: // documentAttributeFilename#15590068
//	case *tg.DocumentAttributeHasStickers: // documentAttributeHasStickers#9801d2f7
//	case *tg.DocumentAttributeCustomEmoji: // documentAttributeCustomEmoji#fd149899
//	default: panic(v)
//	}
type DocumentAttributeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() DocumentAttributeClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeDocumentAttribute implements binary de-serialization for DocumentAttributeClass.
func ( *bin.Buffer) (DocumentAttributeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case DocumentAttributeImageSizeTypeID:
		// Decoding documentAttributeImageSize#6c37c15c.
		 := DocumentAttributeImageSize{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	case DocumentAttributeAnimatedTypeID:
		// Decoding documentAttributeAnimated#11b58939.
		 := DocumentAttributeAnimated{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	case DocumentAttributeStickerTypeID:
		// Decoding documentAttributeSticker#6319d612.
		 := DocumentAttributeSticker{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	case DocumentAttributeVideoTypeID:
		// Decoding documentAttributeVideo#d38ff1c2.
		 := DocumentAttributeVideo{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	case DocumentAttributeAudioTypeID:
		// Decoding documentAttributeAudio#9852f9c6.
		 := DocumentAttributeAudio{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	case DocumentAttributeFilenameTypeID:
		// Decoding documentAttributeFilename#15590068.
		 := DocumentAttributeFilename{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	case DocumentAttributeHasStickersTypeID:
		// Decoding documentAttributeHasStickers#9801d2f7.
		 := DocumentAttributeHasStickers{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	case DocumentAttributeCustomEmojiTypeID:
		// Decoding documentAttributeCustomEmoji#fd149899.
		 := DocumentAttributeCustomEmoji{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode DocumentAttributeClass: %w", bin.NewUnexpectedID())
	}
}

// DocumentAttribute boxes the DocumentAttributeClass providing a helper.
type DocumentAttributeBox struct {
	DocumentAttribute DocumentAttributeClass
}

// Decode implements bin.Decoder for DocumentAttributeBox.
func ( *DocumentAttributeBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode DocumentAttributeBox to nil")
	}
	,  := DecodeDocumentAttribute()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.DocumentAttribute = 
	return nil
}

// Encode implements bin.Encode for DocumentAttributeBox.
func ( *DocumentAttributeBox) ( *bin.Buffer) error {
	if  == nil || .DocumentAttribute == nil {
		return fmt.Errorf("unable to encode DocumentAttributeClass as nil")
	}
	return .DocumentAttribute.Encode()
}