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

// RichButtonStyle represents TL type `richButtonStyle#3c610bd`.
//
// See https://core.telegram.org/constructor/richButtonStyle for reference.
type RichButtonStyle struct {
	// Flags field of RichButtonStyle.
	Flags bin.Fields
	// BgPrimary field of RichButtonStyle.
	BgPrimary bool
	// BgDanger field of RichButtonStyle.
	BgDanger bool
	// BgSuccess field of RichButtonStyle.
	BgSuccess bool
	// Link field of RichButtonStyle.
	Link bool
}

// RichButtonStyleTypeID is TL type id of RichButtonStyle.
const RichButtonStyleTypeID = 0x3c610bd

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

func ( *RichButtonStyle) () 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 !(.Link == false) {
		return false
	}

	return true
}

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

// FillFrom fills RichButtonStyle from given interface.
func ( *RichButtonStyle) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
}) {
	.BgPrimary = .()
	.BgDanger = .()
	.BgSuccess = .()
	.Link = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *RichButtonStyle) () tdp.Type {
	 := tdp.Type{
		Name: "richButtonStyle",
		ID:   RichButtonStyleTypeID,
	}
	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:       "Link",
			SchemaName: "link",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *RichButtonStyle) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode richButtonStyle#3c610bd as nil")
	}
	.PutID(RichButtonStyleTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

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

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

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

// SetLink sets value of Link conditional field.
func ( *RichButtonStyle) ( bool) {
	if  {
		.Flags.Set(3)
		.Link = true
	} else {
		.Flags.Unset(3)
		.Link = false
	}
}

// GetLink returns value of Link conditional field.
func ( *RichButtonStyle) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}