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

// PublicForwardMessage represents TL type `publicForwardMessage#1f2bf4a`.
// Contains info about a forward of a story¹ as a message.
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/constructor/publicForwardMessage for reference.
type PublicForwardMessage struct {
	// Info about the message with the reposted story.
	Message MessageClass
}

// PublicForwardMessageTypeID is TL type id of PublicForwardMessage.
const PublicForwardMessageTypeID = 0x1f2bf4a

// construct implements constructor of PublicForwardClass.
func ( PublicForwardMessage) () PublicForwardClass { return & }

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

	_ PublicForwardClass = &PublicForwardMessage{}
)

func ( *PublicForwardMessage) () bool {
	if  == nil {
		return true
	}
	if !(.Message == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PublicForwardMessage from given interface.
func ( *PublicForwardMessage) ( interface {
	() ( MessageClass)
}) {
	.Message = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PublicForwardMessage) () tdp.Type {
	 := tdp.Type{
		Name: "publicForwardMessage",
		ID:   PublicForwardMessageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Message",
			SchemaName: "message",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PublicForwardMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode publicForwardMessage#1f2bf4a as nil")
	}
	.PutID(PublicForwardMessageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PublicForwardMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode publicForwardMessage#1f2bf4a as nil")
	}
	if .Message == nil {
		return fmt.Errorf("unable to encode publicForwardMessage#1f2bf4a: field message is nil")
	}
	if  := .Message.Encode();  != nil {
		return fmt.Errorf("unable to encode publicForwardMessage#1f2bf4a: field message: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PublicForwardMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode publicForwardMessage#1f2bf4a to nil")
	}
	if  := .ConsumeID(PublicForwardMessageTypeID);  != nil {
		return fmt.Errorf("unable to decode publicForwardMessage#1f2bf4a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PublicForwardMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode publicForwardMessage#1f2bf4a to nil")
	}
	{
		,  := DecodeMessage()
		if  != nil {
			return fmt.Errorf("unable to decode publicForwardMessage#1f2bf4a: field message: %w", )
		}
		.Message = 
	}
	return nil
}

// GetMessage returns value of Message field.
func ( *PublicForwardMessage) () ( MessageClass) {
	if  == nil {
		return
	}
	return .Message
}

// PublicForwardStory represents TL type `publicForwardStory#edf3add0`.
// Contains info about a forward of a story¹ as a repost by a public channel.
//
// Links:
//  1. https://core.telegram.org/api/stories
//
// See https://core.telegram.org/constructor/publicForwardStory for reference.
type PublicForwardStory struct {
	// The channel that reposted the story.
	Peer PeerClass
	// The reposted story (may be different from the original story).
	Story StoryItemClass
}

// PublicForwardStoryTypeID is TL type id of PublicForwardStory.
const PublicForwardStoryTypeID = 0xedf3add0

// construct implements constructor of PublicForwardClass.
func ( PublicForwardStory) () PublicForwardClass { return & }

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

	_ PublicForwardClass = &PublicForwardStory{}
)

func ( *PublicForwardStory) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Story == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PublicForwardStory from given interface.
func ( *PublicForwardStory) ( interface {
	() ( PeerClass)
	() ( StoryItemClass)
}) {
	.Peer = .()
	.Story = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PublicForwardStory) () tdp.Type {
	 := tdp.Type{
		Name: "publicForwardStory",
		ID:   PublicForwardStoryTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Story",
			SchemaName: "story",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PublicForwardStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode publicForwardStory#edf3add0 as nil")
	}
	.PutID(PublicForwardStoryTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PublicForwardStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode publicForwardStory#edf3add0 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode publicForwardStory#edf3add0: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode publicForwardStory#edf3add0: field peer: %w", )
	}
	if .Story == nil {
		return fmt.Errorf("unable to encode publicForwardStory#edf3add0: field story is nil")
	}
	if  := .Story.Encode();  != nil {
		return fmt.Errorf("unable to encode publicForwardStory#edf3add0: field story: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PublicForwardStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode publicForwardStory#edf3add0 to nil")
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode publicForwardStory#edf3add0: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeStoryItem()
		if  != nil {
			return fmt.Errorf("unable to decode publicForwardStory#edf3add0: field story: %w", )
		}
		.Story = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *PublicForwardStory) () ( PeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetStory returns value of Story field.
func ( *PublicForwardStory) () ( StoryItemClass) {
	if  == nil {
		return
	}
	return .Story
}

// PublicForwardClassName is schema name of PublicForwardClass.
const PublicForwardClassName = "PublicForward"

// PublicForwardClass represents PublicForward generic type.
//
// See https://core.telegram.org/type/PublicForward for reference.
//
// Example:
//
//	g, err := tg.DecodePublicForward(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PublicForwardMessage: // publicForwardMessage#1f2bf4a
//	case *tg.PublicForwardStory: // publicForwardStory#edf3add0
//	default: panic(v)
//	}
type PublicForwardClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PublicForwardClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodePublicForward implements binary de-serialization for PublicForwardClass.
func ( *bin.Buffer) (PublicForwardClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PublicForwardMessageTypeID:
		// Decoding publicForwardMessage#1f2bf4a.
		 := PublicForwardMessage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PublicForwardClass: %w", )
		}
		return &, nil
	case PublicForwardStoryTypeID:
		// Decoding publicForwardStory#edf3add0.
		 := PublicForwardStory{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PublicForwardClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PublicForwardClass: %w", bin.NewUnexpectedID())
	}
}

// PublicForward boxes the PublicForwardClass providing a helper.
type PublicForwardBox struct {
	PublicForward PublicForwardClass
}

// Decode implements bin.Decoder for PublicForwardBox.
func ( *PublicForwardBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode PublicForwardBox to nil")
	}
	,  := DecodePublicForward()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.PublicForward = 
	return nil
}

// Encode implements bin.Encode for PublicForwardBox.
func ( *PublicForwardBox) ( *bin.Buffer) error {
	if  == nil || .PublicForward == nil {
		return fmt.Errorf("unable to encode PublicForwardClass as nil")
	}
	return .PublicForward.Encode()
}