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

// BoolFalse represents TL type `boolFalse#bc799737`.
// Constructor may be interpreted as a booleanfalse value.
//
// See https://core.telegram.org/constructor/boolFalse for reference.
type BoolFalse struct {
}

// BoolFalseTypeID is TL type id of BoolFalse.
const BoolFalseTypeID = 0xbc799737

// construct implements constructor of BoolClass.
func ( BoolFalse) () BoolClass { return & }

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

	_ BoolClass = &BoolFalse{}
)

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

	return true
}

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

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

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

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

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

// EncodeBare implements bin.BareEncoder.
func ( *BoolFalse) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode boolFalse#bc799737 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BoolFalse) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode boolFalse#bc799737 to nil")
	}
	return nil
}

// BoolTrue represents TL type `boolTrue#997275b5`.
// The constructor can be interpreted as a booleantrue value.
//
// See https://core.telegram.org/constructor/boolTrue for reference.
type BoolTrue struct {
}

// BoolTrueTypeID is TL type id of BoolTrue.
const BoolTrueTypeID = 0x997275b5

// construct implements constructor of BoolClass.
func ( BoolTrue) () BoolClass { return & }

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

	_ BoolClass = &BoolTrue{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *BoolTrue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode boolTrue#997275b5 as nil")
	}
	.PutID(BoolTrueTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BoolTrue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode boolTrue#997275b5 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BoolTrue) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode boolTrue#997275b5 to nil")
	}
	return nil
}

// BoolClassName is schema name of BoolClass.
const BoolClassName = "Bool"

// BoolClass represents Bool generic type.
//
// See https://core.telegram.org/type/Bool for reference.
//
// Example:
//
//	g, err := tg.DecodeBool(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.BoolFalse: // boolFalse#bc799737
//	case *tg.BoolTrue: // boolTrue#997275b5
//	default: panic(v)
//	}
type BoolClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() BoolClass

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

// DecodeBool implements binary de-serialization for BoolClass.
func ( *bin.Buffer) (BoolClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case BoolFalseTypeID:
		// Decoding boolFalse#bc799737.
		 := BoolFalse{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BoolClass: %w", )
		}
		return &, nil
	case BoolTrueTypeID:
		// Decoding boolTrue#997275b5.
		 := BoolTrue{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode BoolClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode BoolClass: %w", bin.NewUnexpectedID())
	}
}

// Bool boxes the BoolClass providing a helper.
type BoolBox struct {
	Bool BoolClass
}

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

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