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

// BadMsgNotification represents TL type `bad_msg_notification#a7eff811`.
type BadMsgNotification struct {
	// BadMsgID field of BadMsgNotification.
	BadMsgID int64
	// BadMsgSeqno field of BadMsgNotification.
	BadMsgSeqno int
	// ErrorCode field of BadMsgNotification.
	ErrorCode int
}

// BadMsgNotificationTypeID is TL type id of BadMsgNotification.
const BadMsgNotificationTypeID = 0xa7eff811

// construct implements constructor of BadMsgNotificationClass.
func ( BadMsgNotification) () BadMsgNotificationClass { return & }

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

	_ BadMsgNotificationClass = &BadMsgNotification{}
)

func ( *BadMsgNotification) () bool {
	if  == nil {
		return true
	}
	if !(.BadMsgID == 0) {
		return false
	}
	if !(.BadMsgSeqno == 0) {
		return false
	}
	if !(.ErrorCode == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *BadMsgNotification) () tdp.Type {
	 := tdp.Type{
		Name: "bad_msg_notification",
		ID:   BadMsgNotificationTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BadMsgID",
			SchemaName: "bad_msg_id",
		},
		{
			Name:       "BadMsgSeqno",
			SchemaName: "bad_msg_seqno",
		},
		{
			Name:       "ErrorCode",
			SchemaName: "error_code",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BadMsgNotification) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bad_msg_notification#a7eff811 as nil")
	}
	.PutID(BadMsgNotificationTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BadMsgNotification) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bad_msg_notification#a7eff811 as nil")
	}
	.PutLong(.BadMsgID)
	.PutInt(.BadMsgSeqno)
	.PutInt(.ErrorCode)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BadMsgNotification) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bad_msg_notification#a7eff811 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode bad_msg_notification#a7eff811: field bad_msg_id: %w", )
		}
		.BadMsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode bad_msg_notification#a7eff811: field bad_msg_seqno: %w", )
		}
		.BadMsgSeqno = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode bad_msg_notification#a7eff811: field error_code: %w", )
		}
		.ErrorCode = 
	}
	return nil
}

// GetBadMsgID returns value of BadMsgID field.
func ( *BadMsgNotification) () ( int64) {
	if  == nil {
		return
	}
	return .BadMsgID
}

// GetBadMsgSeqno returns value of BadMsgSeqno field.
func ( *BadMsgNotification) () ( int) {
	if  == nil {
		return
	}
	return .BadMsgSeqno
}

// GetErrorCode returns value of ErrorCode field.
func ( *BadMsgNotification) () ( int) {
	if  == nil {
		return
	}
	return .ErrorCode
}

// BadServerSalt represents TL type `bad_server_salt#edab447b`.
type BadServerSalt struct {
	// BadMsgID field of BadServerSalt.
	BadMsgID int64
	// BadMsgSeqno field of BadServerSalt.
	BadMsgSeqno int
	// ErrorCode field of BadServerSalt.
	ErrorCode int
	// NewServerSalt field of BadServerSalt.
	NewServerSalt int64
}

// BadServerSaltTypeID is TL type id of BadServerSalt.
const BadServerSaltTypeID = 0xedab447b

// construct implements constructor of BadMsgNotificationClass.
func ( BadServerSalt) () BadMsgNotificationClass { return & }

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

	_ BadMsgNotificationClass = &BadServerSalt{}
)

func ( *BadServerSalt) () bool {
	if  == nil {
		return true
	}
	if !(.BadMsgID == 0) {
		return false
	}
	if !(.BadMsgSeqno == 0) {
		return false
	}
	if !(.ErrorCode == 0) {
		return false
	}
	if !(.NewServerSalt == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *BadServerSalt) () tdp.Type {
	 := tdp.Type{
		Name: "bad_server_salt",
		ID:   BadServerSaltTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BadMsgID",
			SchemaName: "bad_msg_id",
		},
		{
			Name:       "BadMsgSeqno",
			SchemaName: "bad_msg_seqno",
		},
		{
			Name:       "ErrorCode",
			SchemaName: "error_code",
		},
		{
			Name:       "NewServerSalt",
			SchemaName: "new_server_salt",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BadServerSalt) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bad_server_salt#edab447b as nil")
	}
	.PutID(BadServerSaltTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BadServerSalt) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bad_server_salt#edab447b as nil")
	}
	.PutLong(.BadMsgID)
	.PutInt(.BadMsgSeqno)
	.PutInt(.ErrorCode)
	.PutLong(.NewServerSalt)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BadServerSalt) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bad_server_salt#edab447b to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode bad_server_salt#edab447b: field bad_msg_id: %w", )
		}
		.BadMsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode bad_server_salt#edab447b: field bad_msg_seqno: %w", )
		}
		.BadMsgSeqno = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode bad_server_salt#edab447b: field error_code: %w", )
		}
		.ErrorCode = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode bad_server_salt#edab447b: field new_server_salt: %w", )
		}
		.NewServerSalt = 
	}
	return nil
}

// GetBadMsgID returns value of BadMsgID field.
func ( *BadServerSalt) () ( int64) {
	if  == nil {
		return
	}
	return .BadMsgID
}

// GetBadMsgSeqno returns value of BadMsgSeqno field.
func ( *BadServerSalt) () ( int) {
	if  == nil {
		return
	}
	return .BadMsgSeqno
}

// GetErrorCode returns value of ErrorCode field.
func ( *BadServerSalt) () ( int) {
	if  == nil {
		return
	}
	return .ErrorCode
}

// GetNewServerSalt returns value of NewServerSalt field.
func ( *BadServerSalt) () ( int64) {
	if  == nil {
		return
	}
	return .NewServerSalt
}

// BadMsgNotificationClassName is schema name of BadMsgNotificationClass.
const BadMsgNotificationClassName = "BadMsgNotification"

// BadMsgNotificationClass represents BadMsgNotification generic type.
//
// Example:
//
//	g, err := mt.DecodeBadMsgNotification(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *mt.BadMsgNotification: // bad_msg_notification#a7eff811
//	case *mt.BadServerSalt: // bad_server_salt#edab447b
//	default: panic(v)
//	}
type BadMsgNotificationClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() BadMsgNotificationClass

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

	// BadMsgID field of BadMsgNotification.
	GetBadMsgID() (value int64)
	// BadMsgSeqno field of BadMsgNotification.
	GetBadMsgSeqno() (value int)
	// ErrorCode field of BadMsgNotification.
	GetErrorCode() (value int)
}

// DecodeBadMsgNotification implements binary de-serialization for BadMsgNotificationClass.
func ( *bin.Buffer) (BadMsgNotificationClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case BadMsgNotificationTypeID:
		// Decoding bad_msg_notification#a7eff811.
		 := BadMsgNotification{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BadMsgNotificationClass: %w", )
		}
		return &, nil
	case BadServerSaltTypeID:
		// Decoding bad_server_salt#edab447b.
		 := BadServerSalt{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BadMsgNotificationClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode BadMsgNotificationClass: %w", bin.NewUnexpectedID())
	}
}

// BadMsgNotification boxes the BadMsgNotificationClass providing a helper.
type BadMsgNotificationBox struct {
	BadMsgNotification BadMsgNotificationClass
}

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

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