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

// StoriesCanSendStoryCount represents TL type `stories.canSendStoryCount#c387c04e`.
// Contains the number of available active story slots (equal to the value of the
// story_expiring_limit_* client configuration parameter¹ minus the number of currently
// active stories).
//
// Links:
//  1. https://core.telegram.org/api/config#story-expiring-limit-default
//
// See https://core.telegram.org/constructor/stories.canSendStoryCount for reference.
type StoriesCanSendStoryCount struct {
	// Remaining active story slots.
	CountRemains int
}

// StoriesCanSendStoryCountTypeID is TL type id of StoriesCanSendStoryCount.
const StoriesCanSendStoryCountTypeID = 0xc387c04e

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

func ( *StoriesCanSendStoryCount) () bool {
	if  == nil {
		return true
	}
	if !(.CountRemains == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesCanSendStoryCount from given interface.
func ( *StoriesCanSendStoryCount) ( interface {
	() ( int)
}) {
	.CountRemains = .()
}

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

// TypeName returns name of type in TL schema.
func (*StoriesCanSendStoryCount) () string {
	return "stories.canSendStoryCount"
}

// TypeInfo returns info about TL type.
func ( *StoriesCanSendStoryCount) () tdp.Type {
	 := tdp.Type{
		Name: "stories.canSendStoryCount",
		ID:   StoriesCanSendStoryCountTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "CountRemains",
			SchemaName: "count_remains",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoriesCanSendStoryCount) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.canSendStoryCount#c387c04e as nil")
	}
	.PutID(StoriesCanSendStoryCountTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesCanSendStoryCount) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.canSendStoryCount#c387c04e as nil")
	}
	.PutInt(.CountRemains)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesCanSendStoryCount) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.canSendStoryCount#c387c04e to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.canSendStoryCount#c387c04e: field count_remains: %w", )
		}
		.CountRemains = 
	}
	return nil
}

// GetCountRemains returns value of CountRemains field.
func ( *StoriesCanSendStoryCount) () ( int) {
	if  == nil {
		return
	}
	return .CountRemains
}