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

// MessagesSavedGifsNotModified represents TL type `messages.savedGifsNotModified#e8025ca2`.
// No new saved gifs were found
//
// See https://core.telegram.org/constructor/messages.savedGifsNotModified for reference.
type MessagesSavedGifsNotModified struct {
}

// MessagesSavedGifsNotModifiedTypeID is TL type id of MessagesSavedGifsNotModified.
const MessagesSavedGifsNotModifiedTypeID = 0xe8025ca2

// construct implements constructor of MessagesSavedGifsClass.
func ( MessagesSavedGifsNotModified) () MessagesSavedGifsClass { return & }

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

	_ MessagesSavedGifsClass = &MessagesSavedGifsNotModified{}
)

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

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*MessagesSavedGifsNotModified) () string {
	return "messages.savedGifsNotModified"
}

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

// Encode implements bin.Encoder.
func ( *MessagesSavedGifsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.savedGifsNotModified#e8025ca2 as nil")
	}
	.PutID(MessagesSavedGifsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSavedGifsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.savedGifsNotModified#e8025ca2 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSavedGifsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.savedGifsNotModified#e8025ca2 to nil")
	}
	return nil
}

// MessagesSavedGifs represents TL type `messages.savedGifs#84a02a0d`.
// Saved gifs
//
// See https://core.telegram.org/constructor/messages.savedGifs for reference.
type MessagesSavedGifs struct {
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
	// List of saved gifs
	Gifs []DocumentClass
}

// MessagesSavedGifsTypeID is TL type id of MessagesSavedGifs.
const MessagesSavedGifsTypeID = 0x84a02a0d

// construct implements constructor of MessagesSavedGifsClass.
func ( MessagesSavedGifs) () MessagesSavedGifsClass { return & }

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

	_ MessagesSavedGifsClass = &MessagesSavedGifs{}
)

func ( *MessagesSavedGifs) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.Gifs == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSavedGifs from given interface.
func ( *MessagesSavedGifs) ( interface {
	() ( int64)
	() ( []DocumentClass)
}) {
	.Hash = .()
	.Gifs = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesSavedGifs) () string {
	return "messages.savedGifs"
}

// TypeInfo returns info about TL type.
func ( *MessagesSavedGifs) () tdp.Type {
	 := tdp.Type{
		Name: "messages.savedGifs",
		ID:   MessagesSavedGifsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Gifs",
			SchemaName: "gifs",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesSavedGifs) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.savedGifs#84a02a0d as nil")
	}
	.PutID(MessagesSavedGifsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSavedGifs) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.savedGifs#84a02a0d as nil")
	}
	.PutLong(.Hash)
	.PutVectorHeader(len(.Gifs))
	for ,  := range .Gifs {
		if  == nil {
			return fmt.Errorf("unable to encode messages.savedGifs#84a02a0d: field gifs element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.savedGifs#84a02a0d: field gifs element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSavedGifs) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.savedGifs#84a02a0d to nil")
	}
	if  := .ConsumeID(MessagesSavedGifsTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.savedGifs#84a02a0d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSavedGifs) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.savedGifs#84a02a0d to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.savedGifs#84a02a0d: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.savedGifs#84a02a0d: field gifs: %w", )
		}

		if  > 0 {
			.Gifs = make([]DocumentClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeDocument()
			if  != nil {
				return fmt.Errorf("unable to decode messages.savedGifs#84a02a0d: field gifs: %w", )
			}
			.Gifs = append(.Gifs, )
		}
	}
	return nil
}

// GetHash returns value of Hash field.
func ( *MessagesSavedGifs) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

// GetGifs returns value of Gifs field.
func ( *MessagesSavedGifs) () ( []DocumentClass) {
	if  == nil {
		return
	}
	return .Gifs
}

// MapGifs returns field Gifs wrapped in DocumentClassArray helper.
func ( *MessagesSavedGifs) () ( DocumentClassArray) {
	return DocumentClassArray(.Gifs)
}

// MessagesSavedGifsClassName is schema name of MessagesSavedGifsClass.
const MessagesSavedGifsClassName = "messages.SavedGifs"

// MessagesSavedGifsClass represents messages.SavedGifs generic type.
//
// See https://core.telegram.org/type/messages.SavedGifs for reference.
//
// Example:
//
//	g, err := tg.DecodeMessagesSavedGifs(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.MessagesSavedGifsNotModified: // messages.savedGifsNotModified#e8025ca2
//	case *tg.MessagesSavedGifs: // messages.savedGifs#84a02a0d
//	default: panic(v)
//	}
type MessagesSavedGifsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() MessagesSavedGifsClass

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

	// AsModified tries to map MessagesSavedGifsClass to MessagesSavedGifs.
	AsModified() (*MessagesSavedGifs, bool)
}

// AsModified tries to map MessagesSavedGifsNotModified to MessagesSavedGifs.
func ( *MessagesSavedGifsNotModified) () (*MessagesSavedGifs, bool) {
	return nil, false
}

// AsModified tries to map MessagesSavedGifs to MessagesSavedGifs.
func ( *MessagesSavedGifs) () (*MessagesSavedGifs, bool) {
	return , true
}

// DecodeMessagesSavedGifs implements binary de-serialization for MessagesSavedGifsClass.
func ( *bin.Buffer) (MessagesSavedGifsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case MessagesSavedGifsNotModifiedTypeID:
		// Decoding messages.savedGifsNotModified#e8025ca2.
		 := MessagesSavedGifsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesSavedGifsClass: %w", )
		}
		return &, nil
	case MessagesSavedGifsTypeID:
		// Decoding messages.savedGifs#84a02a0d.
		 := MessagesSavedGifs{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode MessagesSavedGifsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode MessagesSavedGifsClass: %w", bin.NewUnexpectedID())
	}
}

// MessagesSavedGifs boxes the MessagesSavedGifsClass providing a helper.
type MessagesSavedGifsBox struct {
	SavedGifs MessagesSavedGifsClass
}

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

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