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

// FileHash represents TL type `fileHash#f39b035c`.
//
// See https://core.telegram.org/constructor/fileHash for reference.
type FileHash struct {
	// Offset field of FileHash.
	Offset int64
	// Limit field of FileHash.
	Limit int
	// Hash field of FileHash.
	Hash []byte
}

// FileHashTypeID is TL type id of FileHash.
const FileHashTypeID = 0xf39b035c

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

func ( *FileHash) () bool {
	if  == nil {
		return true
	}
	if !(.Offset == 0) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}
	if !(.Hash == nil) {
		return false
	}

	return true
}

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

// FillFrom fills FileHash from given interface.
func ( *FileHash) ( interface {
	() ( int64)
	() ( int)
	() ( []byte)
}) {
	.Offset = .()
	.Limit = .()
	.Hash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *FileHash) () tdp.Type {
	 := tdp.Type{
		Name: "fileHash",
		ID:   FileHashTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *FileHash) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode fileHash#f39b035c as nil")
	}
	.PutID(FileHashTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *FileHash) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode fileHash#f39b035c as nil")
	}
	.PutLong(.Offset)
	.PutInt(.Limit)
	.PutBytes(.Hash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *FileHash) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode fileHash#f39b035c to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode fileHash#f39b035c: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode fileHash#f39b035c: field limit: %w", )
		}
		.Limit = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode fileHash#f39b035c: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

// GetOffset returns value of Offset field.
func ( *FileHash) () ( int64) {
	if  == nil {
		return
	}
	return .Offset
}

// GetLimit returns value of Limit field.
func ( *FileHash) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// GetHash returns value of Hash field.
func ( *FileHash) () ( []byte) {
	if  == nil {
		return
	}
	return .Hash
}