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

// StoriesStories represents TL type `stories.stories#5dd8c3c8`.
// List of storiesĀ¹
//
// Links:
//  1. https://core.telegram.org/api/stories#pinned-or-archived-stories
//
// See https://core.telegram.org/constructor/stories.stories for reference.
type StoriesStories struct {
	// Total number of stories that can be fetched
	Count int
	// Stories
	Stories []StoryItemClass
	// Mentioned chats
	Chats []ChatClass
	// Mentioned users
	Users []UserClass
}

// StoriesStoriesTypeID is TL type id of StoriesStories.
const StoriesStoriesTypeID = 0x5dd8c3c8

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

func ( *StoriesStories) () bool {
	if  == nil {
		return true
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Stories == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesStories from given interface.
func ( *StoriesStories) ( interface {
	() ( int)
	() ( []StoryItemClass)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Count = .()
	.Stories = .()
	.Chats = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StoriesStories) () tdp.Type {
	 := tdp.Type{
		Name: "stories.stories",
		ID:   StoriesStoriesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Stories",
			SchemaName: "stories",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StoriesStories) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.stories#5dd8c3c8 as nil")
	}
	.PutID(StoriesStoriesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesStories) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.stories#5dd8c3c8 as nil")
	}
	.PutInt(.Count)
	.PutVectorHeader(len(.Stories))
	for ,  := range .Stories {
		if  == nil {
			return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field stories element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field stories element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.stories#5dd8c3c8: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesStories) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.stories#5dd8c3c8 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field stories: %w", )
		}

		if  > 0 {
			.Stories = make([]StoryItemClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStoryItem()
			if  != nil {
				return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field stories: %w", )
			}
			.Stories = append(.Stories, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode stories.stories#5dd8c3c8: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetCount returns value of Count field.
func ( *StoriesStories) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

// GetStories returns value of Stories field.
func ( *StoriesStories) () ( []StoryItemClass) {
	if  == nil {
		return
	}
	return .Stories
}

// GetChats returns value of Chats field.
func ( *StoriesStories) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

// GetUsers returns value of Users field.
func ( *StoriesStories) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapStories returns field Stories wrapped in StoryItemClassArray helper.
func ( *StoriesStories) () ( StoryItemClassArray) {
	return StoryItemClassArray(.Stories)
}

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *StoriesStories) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *StoriesStories) () ( UserClassArray) {
	return UserClassArray(.Users)
}