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

// StoriesAlbumsNotModified represents TL type `stories.albumsNotModified#564edaeb`.
// The story album list »¹ hasn't changed.
//
// Links:
//  1. https://core.telegram.org/api/stories#story-albums
//
// See https://core.telegram.org/constructor/stories.albumsNotModified for reference.
type StoriesAlbumsNotModified struct {
}

// StoriesAlbumsNotModifiedTypeID is TL type id of StoriesAlbumsNotModified.
const StoriesAlbumsNotModifiedTypeID = 0x564edaeb

// construct implements constructor of StoriesAlbumsClass.
func ( StoriesAlbumsNotModified) () StoriesAlbumsClass { return & }

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

	_ StoriesAlbumsClass = &StoriesAlbumsNotModified{}
)

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

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*StoriesAlbumsNotModified) () string {
	return "stories.albumsNotModified"
}

// TypeInfo returns info about TL type.
func ( *StoriesAlbumsNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "stories.albumsNotModified",
		ID:   StoriesAlbumsNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *StoriesAlbumsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.albumsNotModified#564edaeb as nil")
	}
	.PutID(StoriesAlbumsNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesAlbumsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.albumsNotModified#564edaeb as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StoriesAlbumsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.albumsNotModified#564edaeb to nil")
	}
	if  := .ConsumeID(StoriesAlbumsNotModifiedTypeID);  != nil {
		return fmt.Errorf("unable to decode stories.albumsNotModified#564edaeb: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StoriesAlbumsNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.albumsNotModified#564edaeb to nil")
	}
	return nil
}

// StoriesAlbums represents TL type `stories.albums#c3987a3a`.
// Story albums »¹.
//
// Links:
//  1. https://core.telegram.org/api/stories#story-albums
//
// See https://core.telegram.org/constructor/stories.albums for reference.
type StoriesAlbums struct {
	// Hash to pass to stories.getAlbums¹ to avoid returning any results if they haven't
	// changed.
	//
	// Links:
	//  1) https://core.telegram.org/method/stories.getAlbums
	Hash int64
	// The albums.
	Albums []StoryAlbum
}

// StoriesAlbumsTypeID is TL type id of StoriesAlbums.
const StoriesAlbumsTypeID = 0xc3987a3a

// construct implements constructor of StoriesAlbumsClass.
func ( StoriesAlbums) () StoriesAlbumsClass { return & }

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

	_ StoriesAlbumsClass = &StoriesAlbums{}
)

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

	return true
}

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

// FillFrom fills StoriesAlbums from given interface.
func ( *StoriesAlbums) ( interface {
	() ( int64)
	() ( []StoryAlbum)
}) {
	.Hash = .()
	.Albums = .()
}

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

// TypeName returns name of type in TL schema.
func (*StoriesAlbums) () string {
	return "stories.albums"
}

// TypeInfo returns info about TL type.
func ( *StoriesAlbums) () tdp.Type {
	 := tdp.Type{
		Name: "stories.albums",
		ID:   StoriesAlbumsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Albums",
			SchemaName: "albums",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoriesAlbums) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.albums#c3987a3a as nil")
	}
	.PutID(StoriesAlbumsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesAlbums) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.albums#c3987a3a as nil")
	}
	.PutLong(.Hash)
	.PutVectorHeader(len(.Albums))
	for ,  := range .Albums {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.albums#c3987a3a: field albums element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesAlbums) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.albums#c3987a3a to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode stories.albums#c3987a3a: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.albums#c3987a3a: field albums: %w", )
		}

		if  > 0 {
			.Albums = make([]StoryAlbum, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StoryAlbum
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode stories.albums#c3987a3a: field albums: %w", )
			}
			.Albums = append(.Albums, )
		}
	}
	return nil
}

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

// GetAlbums returns value of Albums field.
func ( *StoriesAlbums) () ( []StoryAlbum) {
	if  == nil {
		return
	}
	return .Albums
}

// StoriesAlbumsClassName is schema name of StoriesAlbumsClass.
const StoriesAlbumsClassName = "stories.Albums"

// StoriesAlbumsClass represents stories.Albums generic type.
//
// See https://core.telegram.org/type/stories.Albums for reference.
//
// Constructors:
//   - [StoriesAlbumsNotModified]
//   - [StoriesAlbums]
//
// Example:
//
//	g, err := tg.DecodeStoriesAlbums(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StoriesAlbumsNotModified: // stories.albumsNotModified#564edaeb
//	case *tg.StoriesAlbums: // stories.albums#c3987a3a
//	default: panic(v)
//	}
type StoriesAlbumsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StoriesAlbumsClass

	// 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 StoriesAlbumsClass to StoriesAlbums.
	AsModified() (*StoriesAlbums, bool)
}

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

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

// DecodeStoriesAlbums implements binary de-serialization for StoriesAlbumsClass.
func ( *bin.Buffer) (StoriesAlbumsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StoriesAlbumsNotModifiedTypeID:
		// Decoding stories.albumsNotModified#564edaeb.
		 := StoriesAlbumsNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoriesAlbumsClass: %w", )
		}
		return &, nil
	case StoriesAlbumsTypeID:
		// Decoding stories.albums#c3987a3a.
		 := StoriesAlbums{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StoriesAlbumsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StoriesAlbumsClass: %w", bin.NewUnexpectedID())
	}
}

// StoriesAlbums boxes the StoriesAlbumsClass providing a helper.
type StoriesAlbumsBox struct {
	Albums StoriesAlbumsClass
}

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

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