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

// KeyboardButtonStyle represents TL type `keyboardButtonStyle#4fdd3430`.
// This constructor allows setting a custom background color and custom emoji label for a
// button, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/bots/buttons#button-styles
//
// See https://core.telegram.org/constructor/keyboardButtonStyle for reference.
type KeyboardButtonStyle struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// A dark blue color, recommended for main actions.
	BgPrimary bool
	// A red color, recommended for destructive actions.
	BgDanger bool
	// A green color, recommended for positive actions.
	BgSuccess bool
	// The ID of a custom emoji¹ to be displayed before the button's label.
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	//
	// Use SetIcon and GetIcon helpers.
	Icon int64
}

// KeyboardButtonStyleTypeID is TL type id of KeyboardButtonStyle.
const KeyboardButtonStyleTypeID = 0x4fdd3430

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

func ( *KeyboardButtonStyle) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.BgPrimary == false) {
		return false
	}
	if !(.BgDanger == false) {
		return false
	}
	if !(.BgSuccess == false) {
		return false
	}
	if !(.Icon == 0) {
		return false
	}

	return true
}

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

// FillFrom fills KeyboardButtonStyle from given interface.
func ( *KeyboardButtonStyle) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64,  bool)
}) {
	.BgPrimary = .()
	.BgDanger = .()
	.BgSuccess = .()
	if ,  := .();  {
		.Icon = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *KeyboardButtonStyle) () tdp.Type {
	 := tdp.Type{
		Name: "keyboardButtonStyle",
		ID:   KeyboardButtonStyleTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BgPrimary",
			SchemaName: "bg_primary",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "BgDanger",
			SchemaName: "bg_danger",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "BgSuccess",
			SchemaName: "bg_success",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Icon",
			SchemaName: "icon",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *KeyboardButtonStyle) () {
	if !(.BgPrimary == false) {
		.Flags.Set(0)
	}
	if !(.BgDanger == false) {
		.Flags.Set(1)
	}
	if !(.BgSuccess == false) {
		.Flags.Set(2)
	}
	if !(.Icon == 0) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *KeyboardButtonStyle) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode keyboardButtonStyle#4fdd3430 as nil")
	}
	.PutID(KeyboardButtonStyleTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *KeyboardButtonStyle) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode keyboardButtonStyle#4fdd3430 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode keyboardButtonStyle#4fdd3430: field flags: %w", )
	}
	if .Flags.Has(3) {
		.PutLong(.Icon)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *KeyboardButtonStyle) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode keyboardButtonStyle#4fdd3430 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode keyboardButtonStyle#4fdd3430: field flags: %w", )
		}
	}
	.BgPrimary = .Flags.Has(0)
	.BgDanger = .Flags.Has(1)
	.BgSuccess = .Flags.Has(2)
	if .Flags.Has(3) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode keyboardButtonStyle#4fdd3430: field icon: %w", )
		}
		.Icon = 
	}
	return nil
}

// SetBgPrimary sets value of BgPrimary conditional field.
func ( *KeyboardButtonStyle) ( bool) {
	if  {
		.Flags.Set(0)
		.BgPrimary = true
	} else {
		.Flags.Unset(0)
		.BgPrimary = false
	}
}

// GetBgPrimary returns value of BgPrimary conditional field.
func ( *KeyboardButtonStyle) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetBgDanger sets value of BgDanger conditional field.
func ( *KeyboardButtonStyle) ( bool) {
	if  {
		.Flags.Set(1)
		.BgDanger = true
	} else {
		.Flags.Unset(1)
		.BgDanger = false
	}
}

// GetBgDanger returns value of BgDanger conditional field.
func ( *KeyboardButtonStyle) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetBgSuccess sets value of BgSuccess conditional field.
func ( *KeyboardButtonStyle) ( bool) {
	if  {
		.Flags.Set(2)
		.BgSuccess = true
	} else {
		.Flags.Unset(2)
		.BgSuccess = false
	}
}

// GetBgSuccess returns value of BgSuccess conditional field.
func ( *KeyboardButtonStyle) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetIcon sets value of Icon conditional field.
func ( *KeyboardButtonStyle) ( int64) {
	.Flags.Set(3)
	.Icon = 
}

// GetIcon returns value of Icon conditional field and
// boolean which is true if field was set.
func ( *KeyboardButtonStyle) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .Icon, true
}