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

// Error represents TL type `error#c4b9f9bb`.
// Error.
//
// See https://core.telegram.org/constructor/error for reference.
type Error struct {
	// Error code
	Code int
	// Message
	Text string
}

// ErrorTypeID is TL type id of Error.
const ErrorTypeID = 0xc4b9f9bb

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

func ( *Error) () bool {
	if  == nil {
		return true
	}
	if !(.Code == 0) {
		return false
	}
	if !(.Text == "") {
		return false
	}

	return true
}

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

// FillFrom fills Error from given interface.
func ( *Error) ( interface {
	() ( int)
	() ( string)
}) {
	.Code = .()
	.Text = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *Error) () tdp.Type {
	 := tdp.Type{
		Name: "error",
		ID:   ErrorTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Code",
			SchemaName: "code",
		},
		{
			Name:       "Text",
			SchemaName: "text",
		},
	}
	return 
}

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

// EncodeBare implements bin.BareEncoder.
func ( *Error) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode error#c4b9f9bb as nil")
	}
	.PutInt(.Code)
	.PutString(.Text)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *Error) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode error#c4b9f9bb to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode error#c4b9f9bb: field code: %w", )
		}
		.Code = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode error#c4b9f9bb: field text: %w", )
		}
		.Text = 
	}
	return nil
}

// GetCode returns value of Code field.
func ( *Error) () ( int) {
	if  == nil {
		return
	}
	return .Code
}

// GetText returns value of Text field.
func ( *Error) () ( string) {
	if  == nil {
		return
	}
	return .Text
}