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

// SearchResultsCalendarPeriod represents TL type `searchResultsCalendarPeriod#c9b0539f`.
// Information about found messages sent on a specific day, used to split the messages in
// messages.searchResultsCalendar¹ constructors by days.
// Multiple searchResultsCalendarPeriod constructors are returned in messages
// searchResultsCalendar¹, each containing information about the first, last and total
// number of messages matching the filter that were sent on a specific day.
//
// Links:
//  1. https://core.telegram.org/constructor/messages.searchResultsCalendar
//  2. https://core.telegram.org/constructor/messages.searchResultsCalendar
//
// See https://core.telegram.org/constructor/searchResultsCalendarPeriod for reference.
type SearchResultsCalendarPeriod struct {
	// The day this object is referring to.
	Date int
	// First message ID that was sent on this day.
	MinMsgID int
	// Last message ID that was sent on this day.
	MaxMsgID int
	// All messages that were sent on this day.
	Count int
}

// SearchResultsCalendarPeriodTypeID is TL type id of SearchResultsCalendarPeriod.
const SearchResultsCalendarPeriodTypeID = 0xc9b0539f

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

func ( *SearchResultsCalendarPeriod) () bool {
	if  == nil {
		return true
	}
	if !(.Date == 0) {
		return false
	}
	if !(.MinMsgID == 0) {
		return false
	}
	if !(.MaxMsgID == 0) {
		return false
	}
	if !(.Count == 0) {
		return false
	}

	return true
}

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

// FillFrom fills SearchResultsCalendarPeriod from given interface.
func ( *SearchResultsCalendarPeriod) ( interface {
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.Date = .()
	.MinMsgID = .()
	.MaxMsgID = .()
	.Count = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *SearchResultsCalendarPeriod) () tdp.Type {
	 := tdp.Type{
		Name: "searchResultsCalendarPeriod",
		ID:   SearchResultsCalendarPeriodTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "MinMsgID",
			SchemaName: "min_msg_id",
		},
		{
			Name:       "MaxMsgID",
			SchemaName: "max_msg_id",
		},
		{
			Name:       "Count",
			SchemaName: "count",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *SearchResultsCalendarPeriod) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode searchResultsCalendarPeriod#c9b0539f as nil")
	}
	.PutID(SearchResultsCalendarPeriodTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *SearchResultsCalendarPeriod) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode searchResultsCalendarPeriod#c9b0539f as nil")
	}
	.PutInt(.Date)
	.PutInt(.MinMsgID)
	.PutInt(.MaxMsgID)
	.PutInt(.Count)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *SearchResultsCalendarPeriod) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode searchResultsCalendarPeriod#c9b0539f to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode searchResultsCalendarPeriod#c9b0539f: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode searchResultsCalendarPeriod#c9b0539f: field min_msg_id: %w", )
		}
		.MinMsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode searchResultsCalendarPeriod#c9b0539f: field max_msg_id: %w", )
		}
		.MaxMsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode searchResultsCalendarPeriod#c9b0539f: field count: %w", )
		}
		.Count = 
	}
	return nil
}

// GetDate returns value of Date field.
func ( *SearchResultsCalendarPeriod) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetMinMsgID returns value of MinMsgID field.
func ( *SearchResultsCalendarPeriod) () ( int) {
	if  == nil {
		return
	}
	return .MinMsgID
}

// GetMaxMsgID returns value of MaxMsgID field.
func ( *SearchResultsCalendarPeriod) () ( int) {
	if  == nil {
		return
	}
	return .MaxMsgID
}

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