// Code generated by gotdgen, DO NOT EDIT.

package mt

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

// DestroySessionOk represents TL type `destroy_session_ok#e22045fc`.
type DestroySessionOk struct {
	// SessionID field of DestroySessionOk.
	SessionID int64
}

// DestroySessionOkTypeID is TL type id of DestroySessionOk.
const DestroySessionOkTypeID = 0xe22045fc

// construct implements constructor of DestroySessionResClass.
func ( DestroySessionOk) () DestroySessionResClass { return & }

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

	_ DestroySessionResClass = &DestroySessionOk{}
)

func ( *DestroySessionOk) () bool {
	if  == nil {
		return true
	}
	if !(.SessionID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *DestroySessionOk) () tdp.Type {
	 := tdp.Type{
		Name: "destroy_session_ok",
		ID:   DestroySessionOkTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "SessionID",
			SchemaName: "session_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DestroySessionOk) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode destroy_session_ok#e22045fc as nil")
	}
	.PutID(DestroySessionOkTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DestroySessionOk) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode destroy_session_ok#e22045fc as nil")
	}
	.PutLong(.SessionID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DestroySessionOk) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode destroy_session_ok#e22045fc to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode destroy_session_ok#e22045fc: field session_id: %w", )
		}
		.SessionID = 
	}
	return nil
}

// GetSessionID returns value of SessionID field.
func ( *DestroySessionOk) () ( int64) {
	if  == nil {
		return
	}
	return .SessionID
}

// DestroySessionNone represents TL type `destroy_session_none#62d350c9`.
type DestroySessionNone struct {
	// SessionID field of DestroySessionNone.
	SessionID int64
}

// DestroySessionNoneTypeID is TL type id of DestroySessionNone.
const DestroySessionNoneTypeID = 0x62d350c9

// construct implements constructor of DestroySessionResClass.
func ( DestroySessionNone) () DestroySessionResClass { return & }

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

	_ DestroySessionResClass = &DestroySessionNone{}
)

func ( *DestroySessionNone) () bool {
	if  == nil {
		return true
	}
	if !(.SessionID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *DestroySessionNone) () tdp.Type {
	 := tdp.Type{
		Name: "destroy_session_none",
		ID:   DestroySessionNoneTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "SessionID",
			SchemaName: "session_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DestroySessionNone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode destroy_session_none#62d350c9 as nil")
	}
	.PutID(DestroySessionNoneTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DestroySessionNone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode destroy_session_none#62d350c9 as nil")
	}
	.PutLong(.SessionID)
	return nil
}

// Decode implements bin.Decoder.
func ( *DestroySessionNone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode destroy_session_none#62d350c9 to nil")
	}
	if  := .ConsumeID(DestroySessionNoneTypeID);  != nil {
		return fmt.Errorf("unable to decode destroy_session_none#62d350c9: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *DestroySessionNone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode destroy_session_none#62d350c9 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode destroy_session_none#62d350c9: field session_id: %w", )
		}
		.SessionID = 
	}
	return nil
}

// GetSessionID returns value of SessionID field.
func ( *DestroySessionNone) () ( int64) {
	if  == nil {
		return
	}
	return .SessionID
}

// DestroySessionResClassName is schema name of DestroySessionResClass.
const DestroySessionResClassName = "DestroySessionRes"

// DestroySessionResClass represents DestroySessionRes generic type.
//
// Example:
//
//	g, err := mt.DecodeDestroySessionRes(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *mt.DestroySessionOk: // destroy_session_ok#e22045fc
//	case *mt.DestroySessionNone: // destroy_session_none#62d350c9
//	default: panic(v)
//	}
type DestroySessionResClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() DestroySessionResClass

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

	// SessionID field of DestroySessionOk.
	GetSessionID() (value int64)
}

// DecodeDestroySessionRes implements binary de-serialization for DestroySessionResClass.
func ( *bin.Buffer) (DestroySessionResClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case DestroySessionOkTypeID:
		// Decoding destroy_session_ok#e22045fc.
		 := DestroySessionOk{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DestroySessionResClass: %w", )
		}
		return &, nil
	case DestroySessionNoneTypeID:
		// Decoding destroy_session_none#62d350c9.
		 := DestroySessionNone{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DestroySessionResClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode DestroySessionResClass: %w", bin.NewUnexpectedID())
	}
}

// DestroySessionRes boxes the DestroySessionResClass providing a helper.
type DestroySessionResBox struct {
	DestroySessionRes DestroySessionResClass
}

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

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