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

// RecentStory represents TL type `recentStory#711d692d`.
//
// See https://core.telegram.org/constructor/recentStory for reference.
type RecentStory struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Live field of RecentStory.
	Live bool
	// MaxID field of RecentStory.
	//
	// Use SetMaxID and GetMaxID helpers.
	MaxID int
}

// RecentStoryTypeID is TL type id of RecentStory.
const RecentStoryTypeID = 0x711d692d

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

func ( *RecentStory) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Live == false) {
		return false
	}
	if !(.MaxID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills RecentStory from given interface.
func ( *RecentStory) ( interface {
	() ( bool)
	() ( int,  bool)
}) {
	.Live = .()
	if ,  := .();  {
		.MaxID = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *RecentStory) () tdp.Type {
	 := tdp.Type{
		Name: "recentStory",
		ID:   RecentStoryTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Live",
			SchemaName: "live",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "MaxID",
			SchemaName: "max_id",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *RecentStory) () {
	if !(.Live == false) {
		.Flags.Set(0)
	}
	if !(.MaxID == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *RecentStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode recentStory#711d692d as nil")
	}
	.PutID(RecentStoryTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *RecentStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode recentStory#711d692d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode recentStory#711d692d: field flags: %w", )
	}
	if .Flags.Has(1) {
		.PutInt(.MaxID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *RecentStory) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode recentStory#711d692d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode recentStory#711d692d: field flags: %w", )
		}
	}
	.Live = .Flags.Has(0)
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode recentStory#711d692d: field max_id: %w", )
		}
		.MaxID = 
	}
	return nil
}

// SetLive sets value of Live conditional field.
func ( *RecentStory) ( bool) {
	if  {
		.Flags.Set(0)
		.Live = true
	} else {
		.Flags.Unset(0)
		.Live = false
	}
}

// GetLive returns value of Live conditional field.
func ( *RecentStory) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetMaxID sets value of MaxID conditional field.
func ( *RecentStory) ( int) {
	.Flags.Set(1)
	.MaxID = 
}

// GetMaxID returns value of MaxID conditional field and
// boolean which is true if field was set.
func ( *RecentStory) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .MaxID, true
}