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

// KeyboardButton represents TL type `keyboardButton#2f67a72f`.
// Bot keyboard button
// Available only in reply keyboards¹.
// When pressed, clients must send text as a message to the current chat, replying to the
// message that attached the replyKeyboardMarkup¹.
//
// Links:
//  1. https://core.telegram.org/constructor/replyKeyboardMarkup
//  2. https://core.telegram.org/constructor/replyKeyboardMarkup
//
// See https://core.telegram.org/constructor/keyboardButton for reference.
type KeyboardButton struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Button style, see here »¹ for more info on button styles.
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/buttons#button-styles
	//
	// Use SetStyle and GetStyle helpers.
	Style KeyboardButtonStyle
	// Button text
	Text string
	// Type field of KeyboardButton.
	Type ButtonTypeClass
}

// KeyboardButtonTypeID is TL type id of KeyboardButton.
const KeyboardButtonTypeID = 0x2f67a72f

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

func ( *KeyboardButton) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Style.Zero()) {
		return false
	}
	if !(.Text == "") {
		return false
	}
	if !(.Type == nil) {
		return false
	}

	return true
}

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

// FillFrom fills KeyboardButton from given interface.
func ( *KeyboardButton) ( interface {
	() ( KeyboardButtonStyle,  bool)
	() ( string)
	() ( ButtonTypeClass)
}) {
	if ,  := .();  {
		.Style = 
	}

	.Text = .()
	.Type = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *KeyboardButton) () tdp.Type {
	 := tdp.Type{
		Name: "keyboardButton",
		ID:   KeyboardButtonTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Style",
			SchemaName: "style",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "Type",
			SchemaName: "type",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *KeyboardButton) () {
	if !(.Style.Zero()) {
		.Flags.Set(10)
	}
}

// Encode implements bin.Encoder.
func ( *KeyboardButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode keyboardButton#2f67a72f as nil")
	}
	.PutID(KeyboardButtonTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *KeyboardButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode keyboardButton#2f67a72f as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field flags: %w", )
	}
	if .Flags.Has(10) {
		if  := .Style.Encode();  != nil {
			return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field style: %w", )
		}
	}
	.PutString(.Text)
	if .Type == nil {
		return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field type is nil")
	}
	if  := .Type.Encode();  != nil {
		return fmt.Errorf("unable to encode keyboardButton#2f67a72f: field type: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *KeyboardButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode keyboardButton#2f67a72f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field flags: %w", )
		}
	}
	if .Flags.Has(10) {
		if  := .Style.Decode();  != nil {
			return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field style: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field text: %w", )
		}
		.Text = 
	}
	{
		,  := DecodeButtonType()
		if  != nil {
			return fmt.Errorf("unable to decode keyboardButton#2f67a72f: field type: %w", )
		}
		.Type = 
	}
	return nil
}

// SetStyle sets value of Style conditional field.
func ( *KeyboardButton) ( KeyboardButtonStyle) {
	.Flags.Set(10)
	.Style = 
}

// GetStyle returns value of Style conditional field and
// boolean which is true if field was set.
func ( *KeyboardButton) () ( KeyboardButtonStyle,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(10) {
		return , false
	}
	return .Style, true
}

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

// GetType returns value of Type field.
func ( *KeyboardButton) () ( ButtonTypeClass) {
	if  == nil {
		return
	}
	return .Type
}