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

// RPCError represents TL type `rpc_error#2144ca19`.
type RPCError struct {
	// ErrorCode field of RPCError.
	ErrorCode int
	// ErrorMessage field of RPCError.
	ErrorMessage string
}

// RPCErrorTypeID is TL type id of RPCError.
const RPCErrorTypeID = 0x2144ca19

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

func ( *RPCError) () bool {
	if  == nil {
		return true
	}
	if !(.ErrorCode == 0) {
		return false
	}
	if !(.ErrorMessage == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func ( *RPCError) () tdp.Type {
	 := tdp.Type{
		Name: "rpc_error",
		ID:   RPCErrorTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ErrorCode",
			SchemaName: "error_code",
		},
		{
			Name:       "ErrorMessage",
			SchemaName: "error_message",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *RPCError) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode rpc_error#2144ca19 as nil")
	}
	.PutID(RPCErrorTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RPCError) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode rpc_error#2144ca19 as nil")
	}
	.PutInt(.ErrorCode)
	.PutString(.ErrorMessage)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RPCError) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode rpc_error#2144ca19 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode rpc_error#2144ca19: field error_code: %w", )
		}
		.ErrorCode = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode rpc_error#2144ca19: field error_message: %w", )
		}
		.ErrorMessage = 
	}
	return nil
}

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

// GetErrorMessage returns value of ErrorMessage field.
func ( *RPCError) () ( string) {
	if  == nil {
		return
	}
	return .ErrorMessage
}