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

// AccountSavedRingtonesNotModified represents TL type `account.savedRingtonesNotModified#fbf6e8b1`.
// The notification sound list hasn't changed.
//
// See https://core.telegram.org/constructor/account.savedRingtonesNotModified for reference.
type AccountSavedRingtonesNotModified struct {
}

// AccountSavedRingtonesNotModifiedTypeID is TL type id of AccountSavedRingtonesNotModified.
const AccountSavedRingtonesNotModifiedTypeID = 0xfbf6e8b1

// construct implements constructor of AccountSavedRingtonesClass.
func ( AccountSavedRingtonesNotModified) () AccountSavedRingtonesClass { return & }

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

	_ AccountSavedRingtonesClass = &AccountSavedRingtonesNotModified{}
)

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

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*AccountSavedRingtonesNotModified) () string {
	return "account.savedRingtonesNotModified"
}

// TypeInfo returns info about TL type.
func ( *AccountSavedRingtonesNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "account.savedRingtonesNotModified",
		ID:   AccountSavedRingtonesNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSavedRingtonesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.savedRingtonesNotModified#fbf6e8b1 as nil")
	}
	.PutID(AccountSavedRingtonesNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSavedRingtonesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.savedRingtonesNotModified#fbf6e8b1 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSavedRingtonesNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.savedRingtonesNotModified#fbf6e8b1 to nil")
	}
	return nil
}

// AccountSavedRingtones represents TL type `account.savedRingtones#c1e92cc5`.
// A list of saved notification sounds
//
// See https://core.telegram.org/constructor/account.savedRingtones for reference.
type AccountSavedRingtones struct {
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int64
	// Saved notification sounds
	Ringtones []DocumentClass
}

// AccountSavedRingtonesTypeID is TL type id of AccountSavedRingtones.
const AccountSavedRingtonesTypeID = 0xc1e92cc5

// construct implements constructor of AccountSavedRingtonesClass.
func ( AccountSavedRingtones) () AccountSavedRingtonesClass { return & }

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

	_ AccountSavedRingtonesClass = &AccountSavedRingtones{}
)

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

	return true
}

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

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

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

// TypeName returns name of type in TL schema.
func (*AccountSavedRingtones) () string {
	return "account.savedRingtones"
}

// TypeInfo returns info about TL type.
func ( *AccountSavedRingtones) () tdp.Type {
	 := tdp.Type{
		Name: "account.savedRingtones",
		ID:   AccountSavedRingtonesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "Ringtones",
			SchemaName: "ringtones",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSavedRingtones) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.savedRingtones#c1e92cc5 as nil")
	}
	.PutID(AccountSavedRingtonesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSavedRingtones) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.savedRingtones#c1e92cc5 as nil")
	}
	.PutLong(.Hash)
	.PutVectorHeader(len(.Ringtones))
	for ,  := range .Ringtones {
		if  == nil {
			return fmt.Errorf("unable to encode account.savedRingtones#c1e92cc5: field ringtones element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.savedRingtones#c1e92cc5: field ringtones element with index %d: %w", , )
		}
	}
	return nil
}

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

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

		if  > 0 {
			.Ringtones = make([]DocumentClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeDocument()
			if  != nil {
				return fmt.Errorf("unable to decode account.savedRingtones#c1e92cc5: field ringtones: %w", )
			}
			.Ringtones = append(.Ringtones, )
		}
	}
	return nil
}

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

// GetRingtones returns value of Ringtones field.
func ( *AccountSavedRingtones) () ( []DocumentClass) {
	if  == nil {
		return
	}
	return .Ringtones
}

// MapRingtones returns field Ringtones wrapped in DocumentClassArray helper.
func ( *AccountSavedRingtones) () ( DocumentClassArray) {
	return DocumentClassArray(.Ringtones)
}

// AccountSavedRingtonesClassName is schema name of AccountSavedRingtonesClass.
const AccountSavedRingtonesClassName = "account.SavedRingtones"

// AccountSavedRingtonesClass represents account.SavedRingtones generic type.
//
// See https://core.telegram.org/type/account.SavedRingtones for reference.
//
// Example:
//
//	g, err := tg.DecodeAccountSavedRingtones(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AccountSavedRingtonesNotModified: // account.savedRingtonesNotModified#fbf6e8b1
//	case *tg.AccountSavedRingtones: // account.savedRingtones#c1e92cc5
//	default: panic(v)
//	}
type AccountSavedRingtonesClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AccountSavedRingtonesClass

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

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

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

// DecodeAccountSavedRingtones implements binary de-serialization for AccountSavedRingtonesClass.
func ( *bin.Buffer) (AccountSavedRingtonesClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AccountSavedRingtonesNotModifiedTypeID:
		// Decoding account.savedRingtonesNotModified#fbf6e8b1.
		 := AccountSavedRingtonesNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountSavedRingtonesClass: %w", )
		}
		return &, nil
	case AccountSavedRingtonesTypeID:
		// Decoding account.savedRingtones#c1e92cc5.
		 := AccountSavedRingtones{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountSavedRingtonesClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AccountSavedRingtonesClass: %w", bin.NewUnexpectedID())
	}
}

// AccountSavedRingtones boxes the AccountSavedRingtonesClass providing a helper.
type AccountSavedRingtonesBox struct {
	SavedRingtones AccountSavedRingtonesClass
}

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

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