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

// StoriesPeerStories represents TL type `stories.peerStories#cae68768`.
// Active story list¹ of a specific peer.
//
// Links:
//  1. https://core.telegram.org/api/stories#watching-stories
//
// See https://core.telegram.org/constructor/stories.peerStories for reference.
type StoriesPeerStories struct {
	// Stories
	Stories PeerStories
	// Mentioned chats
	Chats []ChatClass
	// Mentioned users
	Users []UserClass
}

// StoriesPeerStoriesTypeID is TL type id of StoriesPeerStories.
const StoriesPeerStoriesTypeID = 0xcae68768

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

func ( *StoriesPeerStories) () bool {
	if  == nil {
		return true
	}
	if !(.Stories.Zero()) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StoriesPeerStories from given interface.
func ( *StoriesPeerStories) ( interface {
	() ( PeerStories)
	() ( []ChatClass)
	() ( []UserClass)
}) {
	.Stories = .()
	.Chats = .()
	.Users = .()
}

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

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

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

// Encode implements bin.Encoder.
func ( *StoriesPeerStories) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.peerStories#cae68768 as nil")
	}
	.PutID(StoriesPeerStoriesTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesPeerStories) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.peerStories#cae68768 to nil")
	}
	{
		if  := .Stories.Decode();  != nil {
			return fmt.Errorf("unable to decode stories.peerStories#cae68768: field stories: %w", )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.peerStories#cae68768: field chats: %w", )
		}

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

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

// GetStories returns value of Stories field.
func ( *StoriesPeerStories) () ( PeerStories) {
	if  == nil {
		return
	}
	return .Stories
}

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

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

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

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