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

// FoundStory represents TL type `foundStory#e87acbc0`.
// A story found using global story search »¹.
//
// Links:
//  1. https://core.telegram.org/api/stories#searching-stories
//
// See https://core.telegram.org/constructor/foundStory for reference.
type FoundStory struct {
	// The peer that posted the story.
	Peer PeerClass
	// The story.
	Story StoryItemClass
}

// FoundStoryTypeID is TL type id of FoundStory.
const FoundStoryTypeID = 0xe87acbc0

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *FoundStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode foundStory#e87acbc0 as nil")
	}
	.PutID(FoundStoryTypeID)
	return .EncodeBare()
}

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

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

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

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

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