// 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{}
)

// InputPhotoEmpty represents TL type `inputPhotoEmpty#1cd7bf0d`.
// Empty constructor.
//
// See https://core.telegram.org/constructor/inputPhotoEmpty for reference.
type InputPhotoEmpty struct {
}

// InputPhotoEmptyTypeID is TL type id of InputPhotoEmpty.
const InputPhotoEmptyTypeID = 0x1cd7bf0d

// construct implements constructor of InputPhotoClass.
func ( InputPhotoEmpty) () InputPhotoClass { return & }

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

	_ InputPhotoClass = &InputPhotoEmpty{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputPhotoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPhotoEmpty#1cd7bf0d as nil")
	}
	.PutID(InputPhotoEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPhotoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPhotoEmpty#1cd7bf0d as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputPhotoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPhotoEmpty#1cd7bf0d to nil")
	}
	return nil
}

// InputPhoto represents TL type `inputPhoto#3bb3b94a`.
// Defines a photo for further interaction.
//
// See https://core.telegram.org/constructor/inputPhoto for reference.
type InputPhoto struct {
	// Photo identifier
	ID int64
	// access_hash value from the photo¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/constructor/photo
	AccessHash int64
	// File reference¹
	//
	// Links:
	//  1) https://core.telegram.org/api/file_reference
	FileReference []byte
}

// InputPhotoTypeID is TL type id of InputPhoto.
const InputPhotoTypeID = 0x3bb3b94a

// construct implements constructor of InputPhotoClass.
func ( InputPhoto) () InputPhotoClass { return & }

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

	_ InputPhotoClass = &InputPhoto{}
)

func ( *InputPhoto) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.AccessHash == 0) {
		return false
	}
	if !(.FileReference == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputPhoto from given interface.
func ( *InputPhoto) ( interface {
	() ( int64)
	() ( int64)
	() ( []byte)
}) {
	.ID = .()
	.AccessHash = .()
	.FileReference = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPhoto) () tdp.Type {
	 := tdp.Type{
		Name: "inputPhoto",
		ID:   InputPhotoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "AccessHash",
			SchemaName: "access_hash",
		},
		{
			Name:       "FileReference",
			SchemaName: "file_reference",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPhoto#3bb3b94a as nil")
	}
	.PutID(InputPhotoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPhoto#3bb3b94a as nil")
	}
	.PutLong(.ID)
	.PutLong(.AccessHash)
	.PutBytes(.FileReference)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputPhoto) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPhoto#3bb3b94a to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPhoto#3bb3b94a: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputPhoto#3bb3b94a: field access_hash: %w", )
		}
		.AccessHash = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputPhoto#3bb3b94a: field file_reference: %w", )
		}
		.FileReference = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *InputPhoto) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetAccessHash returns value of AccessHash field.
func ( *InputPhoto) () ( int64) {
	if  == nil {
		return
	}
	return .AccessHash
}

// GetFileReference returns value of FileReference field.
func ( *InputPhoto) () ( []byte) {
	if  == nil {
		return
	}
	return .FileReference
}

// InputPhotoClassName is schema name of InputPhotoClass.
const InputPhotoClassName = "InputPhoto"

// InputPhotoClass represents InputPhoto generic type.
//
// See https://core.telegram.org/type/InputPhoto for reference.
//
// Example:
//
//	g, err := tg.DecodeInputPhoto(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputPhotoEmpty: // inputPhotoEmpty#1cd7bf0d
//	case *tg.InputPhoto: // inputPhoto#3bb3b94a
//	default: panic(v)
//	}
type InputPhotoClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputPhotoClass

	// 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

	// AsNotEmpty tries to map InputPhotoClass to InputPhoto.
	AsNotEmpty() (*InputPhoto, bool)
}

// AsNotEmpty tries to map InputPhotoEmpty to InputPhoto.
func ( *InputPhotoEmpty) () (*InputPhoto, bool) {
	return nil, false
}

// AsNotEmpty tries to map InputPhoto to InputPhoto.
func ( *InputPhoto) () (*InputPhoto, bool) {
	return , true
}

// DecodeInputPhoto implements binary de-serialization for InputPhotoClass.
func ( *bin.Buffer) (InputPhotoClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputPhotoEmptyTypeID:
		// Decoding inputPhotoEmpty#1cd7bf0d.
		 := InputPhotoEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPhotoClass: %w", )
		}
		return &, nil
	case InputPhotoTypeID:
		// Decoding inputPhoto#3bb3b94a.
		 := InputPhoto{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPhotoClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputPhotoClass: %w", bin.NewUnexpectedID())
	}
}

// InputPhoto boxes the InputPhotoClass providing a helper.
type InputPhotoBox struct {
	InputPhoto InputPhotoClass
}

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

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