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

// UploadSaveFilePartRequest represents TL type `upload.saveFilePart#b304a621`.
// Saves a part of file for further sending to one of the methods.
//
// See https://core.telegram.org/method/upload.saveFilePart for reference.
type UploadSaveFilePartRequest struct {
	// Random file identifier created by the client
	FileID int64
	// Numerical order of a part
	FilePart int
	// Binary data, content of a part
	Bytes []byte
}

// UploadSaveFilePartRequestTypeID is TL type id of UploadSaveFilePartRequest.
const UploadSaveFilePartRequestTypeID = 0xb304a621

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

func ( *UploadSaveFilePartRequest) () bool {
	if  == nil {
		return true
	}
	if !(.FileID == 0) {
		return false
	}
	if !(.FilePart == 0) {
		return false
	}
	if !(.Bytes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills UploadSaveFilePartRequest from given interface.
func ( *UploadSaveFilePartRequest) ( interface {
	() ( int64)
	() ( int)
	() ( []byte)
}) {
	.FileID = .()
	.FilePart = .()
	.Bytes = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *UploadSaveFilePartRequest) () tdp.Type {
	 := tdp.Type{
		Name: "upload.saveFilePart",
		ID:   UploadSaveFilePartRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FileID",
			SchemaName: "file_id",
		},
		{
			Name:       "FilePart",
			SchemaName: "file_part",
		},
		{
			Name:       "Bytes",
			SchemaName: "bytes",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UploadSaveFilePartRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.saveFilePart#b304a621 as nil")
	}
	.PutID(UploadSaveFilePartRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UploadSaveFilePartRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.saveFilePart#b304a621 as nil")
	}
	.PutLong(.FileID)
	.PutInt(.FilePart)
	.PutBytes(.Bytes)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *UploadSaveFilePartRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.saveFilePart#b304a621 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode upload.saveFilePart#b304a621: field file_id: %w", )
		}
		.FileID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode upload.saveFilePart#b304a621: field file_part: %w", )
		}
		.FilePart = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode upload.saveFilePart#b304a621: field bytes: %w", )
		}
		.Bytes = 
	}
	return nil
}

// GetFileID returns value of FileID field.
func ( *UploadSaveFilePartRequest) () ( int64) {
	if  == nil {
		return
	}
	return .FileID
}

// GetFilePart returns value of FilePart field.
func ( *UploadSaveFilePartRequest) () ( int) {
	if  == nil {
		return
	}
	return .FilePart
}

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

// UploadSaveFilePart invokes method upload.saveFilePart#b304a621 returning error if any.
// Saves a part of file for further sending to one of the methods.
//
// Possible errors:
//
//	400 FILE_PART_EMPTY: The provided file part is empty.
//	400 FILE_PART_INVALID: The file part number is invalid.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//
// See https://core.telegram.org/method/upload.saveFilePart for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *UploadSaveFilePartRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}