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

// PageCaption represents TL type `pageCaption#6f747657`.
// Page caption
//
// See https://core.telegram.org/constructor/pageCaption for reference.
type PageCaption struct {
	// Caption
	Text RichTextClass
	// Credits
	Credit RichTextClass
}

// PageCaptionTypeID is TL type id of PageCaption.
const PageCaptionTypeID = 0x6f747657

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

func ( *PageCaption) () bool {
	if  == nil {
		return true
	}
	if !(.Text == nil) {
		return false
	}
	if !(.Credit == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PageCaption from given interface.
func ( *PageCaption) ( interface {
	() ( RichTextClass)
	() ( RichTextClass)
}) {
	.Text = .()
	.Credit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PageCaption) () tdp.Type {
	 := tdp.Type{
		Name: "pageCaption",
		ID:   PageCaptionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Text",
			SchemaName: "text",
		},
		{
			Name:       "Credit",
			SchemaName: "credit",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PageCaption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageCaption#6f747657 as nil")
	}
	.PutID(PageCaptionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PageCaption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode pageCaption#6f747657 as nil")
	}
	if .Text == nil {
		return fmt.Errorf("unable to encode pageCaption#6f747657: field text is nil")
	}
	if  := .Text.Encode();  != nil {
		return fmt.Errorf("unable to encode pageCaption#6f747657: field text: %w", )
	}
	if .Credit == nil {
		return fmt.Errorf("unable to encode pageCaption#6f747657: field credit is nil")
	}
	if  := .Credit.Encode();  != nil {
		return fmt.Errorf("unable to encode pageCaption#6f747657: field credit: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PageCaption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode pageCaption#6f747657 to nil")
	}
	{
		,  := DecodeRichText()
		if  != nil {
			return fmt.Errorf("unable to decode pageCaption#6f747657: field text: %w", )
		}
		.Text = 
	}
	{
		,  := DecodeRichText()
		if  != nil {
			return fmt.Errorf("unable to decode pageCaption#6f747657: field credit: %w", )
		}
		.Credit = 
	}
	return nil
}

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

// GetCredit returns value of Credit field.
func ( *PageCaption) () ( RichTextClass) {
	if  == nil {
		return
	}
	return .Credit
}