// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"github.com/gotd/td/bin"
	"github.com/gotd/td/tdjson"
	"github.com/gotd/td/tdp"
	"github.com/gotd/td/tgerr"
)

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

// InputChatlistDialogFilter represents TL type `inputChatlistDialogFilter#f3e0da33`.
// Folder ID
//
// See https://core.telegram.org/constructor/inputChatlistDialogFilter for reference.
type InputChatlistDialogFilter struct {
	// Folder¹ ID
	//
	// Links:
	//  1) https://core.telegram.org/api/folders
	FilterID int
}

// InputChatlistDialogFilterTypeID is TL type id of InputChatlistDialogFilter.
const InputChatlistDialogFilterTypeID = 0xf3e0da33

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

func (i *InputChatlistDialogFilter) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.FilterID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputChatlistDialogFilter from given interface.
func (i *InputChatlistDialogFilter) FillFrom(from interface {
	GetFilterID() (value int)
}) {
	i.FilterID = from.GetFilterID()
}

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

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

// TypeInfo returns info about TL type.
func (i *InputChatlistDialogFilter) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputChatlistDialogFilter",
		ID:   InputChatlistDialogFilterTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "FilterID",
			SchemaName: "filter_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputChatlistDialogFilter) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputChatlistDialogFilter#f3e0da33 as nil")
	}
	b.PutID(InputChatlistDialogFilterTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputChatlistDialogFilter) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputChatlistDialogFilter#f3e0da33 as nil")
	}
	b.PutInt(i.FilterID)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputChatlistDialogFilter) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputChatlistDialogFilter#f3e0da33 to nil")
	}
	if err := b.ConsumeID(InputChatlistDialogFilterTypeID); err != nil {
		return fmt.Errorf("unable to decode inputChatlistDialogFilter#f3e0da33: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputChatlistDialogFilter) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputChatlistDialogFilter#f3e0da33 to nil")
	}
	{
		value, err := b.Int()
		if err != nil {
			return fmt.Errorf("unable to decode inputChatlistDialogFilter#f3e0da33: field filter_id: %w", err)
		}
		i.FilterID = value
	}
	return nil
}

// GetFilterID returns value of FilterID field.
func (i *InputChatlistDialogFilter) GetFilterID() (value int) {
	if i == nil {
		return
	}
	return i.FilterID
}
