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

// UploadWebFile represents TL type `upload.webFile#21e753bc`.
// Represents a chunk of an HTTP webfile¹ downloaded through telegram's secure MTProto
// servers
//
// Links:
//  1. https://core.telegram.org/api/files
//
// See https://core.telegram.org/constructor/upload.webFile for reference.
type UploadWebFile struct {
	// File size
	Size int
	// Mime type
	MimeType string
	// File type
	FileType StorageFileTypeClass
	// Modified time
	Mtime int
	// Data
	Bytes []byte
}

// UploadWebFileTypeID is TL type id of UploadWebFile.
const UploadWebFileTypeID = 0x21e753bc

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

func ( *UploadWebFile) () bool {
	if  == nil {
		return true
	}
	if !(.Size == 0) {
		return false
	}
	if !(.MimeType == "") {
		return false
	}
	if !(.FileType == nil) {
		return false
	}
	if !(.Mtime == 0) {
		return false
	}
	if !(.Bytes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills UploadWebFile from given interface.
func ( *UploadWebFile) ( interface {
	() ( int)
	() ( string)
	() ( StorageFileTypeClass)
	() ( int)
	() ( []byte)
}) {
	.Size = .()
	.MimeType = .()
	.FileType = .()
	.Mtime = .()
	.Bytes = .()
}

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

// TypeName returns name of type in TL schema.
func (*UploadWebFile) () string {
	return "upload.webFile"
}

// TypeInfo returns info about TL type.
func ( *UploadWebFile) () tdp.Type {
	 := tdp.Type{
		Name: "upload.webFile",
		ID:   UploadWebFileTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Size",
			SchemaName: "size",
		},
		{
			Name:       "MimeType",
			SchemaName: "mime_type",
		},
		{
			Name:       "FileType",
			SchemaName: "file_type",
		},
		{
			Name:       "Mtime",
			SchemaName: "mtime",
		},
		{
			Name:       "Bytes",
			SchemaName: "bytes",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UploadWebFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.webFile#21e753bc as nil")
	}
	.PutID(UploadWebFileTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UploadWebFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.webFile#21e753bc as nil")
	}
	.PutInt(.Size)
	.PutString(.MimeType)
	if .FileType == nil {
		return fmt.Errorf("unable to encode upload.webFile#21e753bc: field file_type is nil")
	}
	if  := .FileType.Encode();  != nil {
		return fmt.Errorf("unable to encode upload.webFile#21e753bc: field file_type: %w", )
	}
	.PutInt(.Mtime)
	.PutBytes(.Bytes)
	return nil
}

// Decode implements bin.Decoder.
func ( *UploadWebFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.webFile#21e753bc to nil")
	}
	if  := .ConsumeID(UploadWebFileTypeID);  != nil {
		return fmt.Errorf("unable to decode upload.webFile#21e753bc: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UploadWebFile) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.webFile#21e753bc to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode upload.webFile#21e753bc: field size: %w", )
		}
		.Size = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode upload.webFile#21e753bc: field mime_type: %w", )
		}
		.MimeType = 
	}
	{
		,  := DecodeStorageFileType()
		if  != nil {
			return fmt.Errorf("unable to decode upload.webFile#21e753bc: field file_type: %w", )
		}
		.FileType = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode upload.webFile#21e753bc: field mtime: %w", )
		}
		.Mtime = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode upload.webFile#21e753bc: field bytes: %w", )
		}
		.Bytes = 
	}
	return nil
}

// GetSize returns value of Size field.
func ( *UploadWebFile) () ( int) {
	if  == nil {
		return
	}
	return .Size
}

// GetMimeType returns value of MimeType field.
func ( *UploadWebFile) () ( string) {
	if  == nil {
		return
	}
	return .MimeType
}

// GetFileType returns value of FileType field.
func ( *UploadWebFile) () ( StorageFileTypeClass) {
	if  == nil {
		return
	}
	return .FileType
}

// GetMtime returns value of Mtime field.
func ( *UploadWebFile) () ( int) {
	if  == nil {
		return
	}
	return .Mtime
}

// GetBytes returns value of Bytes field.
func ( *UploadWebFile) () ( []byte) {
	if  == nil {
		return
	}
	return .Bytes
}