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

// PageButton represents TL type `pageButton#692a5488`.
//
// See https://core.telegram.org/constructor/pageButton for reference.
type PageButton struct {
	// Flags field of PageButton.
	Flags bin.Fields
	// Text field of PageButton.
	Text RichTextClass
	// Type field of PageButton.
	Type InlineButtonTypeClass
	// Style field of PageButton.
	//
	// Use SetStyle and GetStyle helpers.
	Style RichButtonStyle
}

// PageButtonTypeID is TL type id of PageButton.
const PageButtonTypeID = 0x692a5488

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

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

	return true
}

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

// FillFrom fills PageButton from given interface.
func ( *PageButton) ( interface {
	() ( RichTextClass)
	() ( InlineButtonTypeClass)
	() ( RichButtonStyle,  bool)
}) {
	.Text = .()
	.Type = .()
	if ,  := .();  {
		.Style = 
	}

}

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

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

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

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

// Encode implements bin.Encoder.
func ( *PageButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageButton#692a5488 as nil")
	}
	.PutID(PageButtonTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PageButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageButton#692a5488 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode pageButton#692a5488: field flags: %w", )
	}
	if .Text == nil {
		return fmt.Errorf("unable to encode pageButton#692a5488: field text is nil")
	}
	if  := .Text.Encode();  != nil {
		return fmt.Errorf("unable to encode pageButton#692a5488: field text: %w", )
	}
	if .Type == nil {
		return fmt.Errorf("unable to encode pageButton#692a5488: field type is nil")
	}
	if  := .Type.Encode();  != nil {
		return fmt.Errorf("unable to encode pageButton#692a5488: field type: %w", )
	}
	if .Flags.Has(0) {
		if  := .Style.Encode();  != nil {
			return fmt.Errorf("unable to encode pageButton#692a5488: field style: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PageButton) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode pageButton#692a5488 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode pageButton#692a5488: field flags: %w", )
		}
	}
	{
		,  := DecodeRichText()
		if  != nil {
			return fmt.Errorf("unable to decode pageButton#692a5488: field text: %w", )
		}
		.Text = 
	}
	{
		,  := DecodeInlineButtonType()
		if  != nil {
			return fmt.Errorf("unable to decode pageButton#692a5488: field type: %w", )
		}
		.Type = 
	}
	if .Flags.Has(0) {
		if  := .Style.Decode();  != nil {
			return fmt.Errorf("unable to decode pageButton#692a5488: field style: %w", )
		}
	}
	return nil
}

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

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

// SetStyle sets value of Style conditional field.
func ( *PageButton) ( RichButtonStyle) {
	.Flags.Set(0)
	.Style = 
}

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