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

// AccountSavedRingtone represents TL type `account.savedRingtone#b7263f6d`.
// The notification sound was already in MP3 format and was saved without any
// modification
//
// See https://core.telegram.org/constructor/account.savedRingtone for reference.
type AccountSavedRingtone struct {
}

// AccountSavedRingtoneTypeID is TL type id of AccountSavedRingtone.
const AccountSavedRingtoneTypeID = 0xb7263f6d

// construct implements constructor of AccountSavedRingtoneClass.
func ( AccountSavedRingtone) () AccountSavedRingtoneClass { return & }

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

	_ AccountSavedRingtoneClass = &AccountSavedRingtone{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *AccountSavedRingtone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.savedRingtone#b7263f6d as nil")
	}
	.PutID(AccountSavedRingtoneTypeID)
	return .EncodeBare()
}

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

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

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

// AccountSavedRingtoneConverted represents TL type `account.savedRingtoneConverted#1f307eb7`.
// The notification sound was not in MP3 format and was successfully converted and saved,
// use the returned Document¹ to refer to the notification sound from now on
//
// Links:
//  1. https://core.telegram.org/type/Document
//
// See https://core.telegram.org/constructor/account.savedRingtoneConverted for reference.
type AccountSavedRingtoneConverted struct {
	// The converted notification sound
	Document DocumentClass
}

// AccountSavedRingtoneConvertedTypeID is TL type id of AccountSavedRingtoneConverted.
const AccountSavedRingtoneConvertedTypeID = 0x1f307eb7

// construct implements constructor of AccountSavedRingtoneClass.
func ( AccountSavedRingtoneConverted) () AccountSavedRingtoneClass { return & }

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

	_ AccountSavedRingtoneClass = &AccountSavedRingtoneConverted{}
)

func ( *AccountSavedRingtoneConverted) () bool {
	if  == nil {
		return true
	}
	if !(.Document == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSavedRingtoneConverted from given interface.
func ( *AccountSavedRingtoneConverted) ( interface {
	() ( DocumentClass)
}) {
	.Document = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSavedRingtoneConverted) () tdp.Type {
	 := tdp.Type{
		Name: "account.savedRingtoneConverted",
		ID:   AccountSavedRingtoneConvertedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Document",
			SchemaName: "document",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSavedRingtoneConverted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.savedRingtoneConverted#1f307eb7 as nil")
	}
	.PutID(AccountSavedRingtoneConvertedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSavedRingtoneConverted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.savedRingtoneConverted#1f307eb7 as nil")
	}
	if .Document == nil {
		return fmt.Errorf("unable to encode account.savedRingtoneConverted#1f307eb7: field document is nil")
	}
	if  := .Document.Encode();  != nil {
		return fmt.Errorf("unable to encode account.savedRingtoneConverted#1f307eb7: field document: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSavedRingtoneConverted) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.savedRingtoneConverted#1f307eb7 to nil")
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode account.savedRingtoneConverted#1f307eb7: field document: %w", )
		}
		.Document = 
	}
	return nil
}

// GetDocument returns value of Document field.
func ( *AccountSavedRingtoneConverted) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .Document
}

// AccountSavedRingtoneClassName is schema name of AccountSavedRingtoneClass.
const AccountSavedRingtoneClassName = "account.SavedRingtone"

// AccountSavedRingtoneClass represents account.SavedRingtone generic type.
//
// See https://core.telegram.org/type/account.SavedRingtone for reference.
//
// Example:
//
//	g, err := tg.DecodeAccountSavedRingtone(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AccountSavedRingtone: // account.savedRingtone#b7263f6d
//	case *tg.AccountSavedRingtoneConverted: // account.savedRingtoneConverted#1f307eb7
//	default: panic(v)
//	}
type AccountSavedRingtoneClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AccountSavedRingtoneClass

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

// DecodeAccountSavedRingtone implements binary de-serialization for AccountSavedRingtoneClass.
func ( *bin.Buffer) (AccountSavedRingtoneClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AccountSavedRingtoneTypeID:
		// Decoding account.savedRingtone#b7263f6d.
		 := AccountSavedRingtone{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountSavedRingtoneClass: %w", )
		}
		return &, nil
	case AccountSavedRingtoneConvertedTypeID:
		// Decoding account.savedRingtoneConverted#1f307eb7.
		 := AccountSavedRingtoneConverted{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AccountSavedRingtoneClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AccountSavedRingtoneClass: %w", bin.NewUnexpectedID())
	}
}

// AccountSavedRingtone boxes the AccountSavedRingtoneClass providing a helper.
type AccountSavedRingtoneBox struct {
	SavedRingtone AccountSavedRingtoneClass
}

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

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