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

// UpdatesState represents TL type `updates.state#a56c2a3e`.
// Updates state.
//
// See https://core.telegram.org/constructor/updates.state for reference.
type UpdatesState struct {
	// Number of events occurred in a text box
	Pts int
	// Position in a sequence of updates in secret chats. For further details refer to
	// article secret chatsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/end-to-end
	Qts int
	// Date of condition
	Date int
	// Number of sent updates
	Seq int
	// Number of unread messages
	UnreadCount int
}

// UpdatesStateTypeID is TL type id of UpdatesState.
const UpdatesStateTypeID = 0xa56c2a3e

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

func ( *UpdatesState) () bool {
	if  == nil {
		return true
	}
	if !(.Pts == 0) {
		return false
	}
	if !(.Qts == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Seq == 0) {
		return false
	}
	if !(.UnreadCount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills UpdatesState from given interface.
func ( *UpdatesState) ( interface {
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.Pts = .()
	.Qts = .()
	.Date = .()
	.Seq = .()
	.UnreadCount = .()
}

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

// TypeName returns name of type in TL schema.
func (*UpdatesState) () string {
	return "updates.state"
}

// TypeInfo returns info about TL type.
func ( *UpdatesState) () tdp.Type {
	 := tdp.Type{
		Name: "updates.state",
		ID:   UpdatesStateTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pts",
			SchemaName: "pts",
		},
		{
			Name:       "Qts",
			SchemaName: "qts",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Seq",
			SchemaName: "seq",
		},
		{
			Name:       "UnreadCount",
			SchemaName: "unread_count",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UpdatesState) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.state#a56c2a3e as nil")
	}
	.PutID(UpdatesStateTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UpdatesState) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.state#a56c2a3e as nil")
	}
	.PutInt(.Pts)
	.PutInt(.Qts)
	.PutInt(.Date)
	.PutInt(.Seq)
	.PutInt(.UnreadCount)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *UpdatesState) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.state#a56c2a3e to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.state#a56c2a3e: field pts: %w", )
		}
		.Pts = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.state#a56c2a3e: field qts: %w", )
		}
		.Qts = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.state#a56c2a3e: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.state#a56c2a3e: field seq: %w", )
		}
		.Seq = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.state#a56c2a3e: field unread_count: %w", )
		}
		.UnreadCount = 
	}
	return nil
}

// GetPts returns value of Pts field.
func ( *UpdatesState) () ( int) {
	if  == nil {
		return
	}
	return .Pts
}

// GetQts returns value of Qts field.
func ( *UpdatesState) () ( int) {
	if  == nil {
		return
	}
	return .Qts
}

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

// GetSeq returns value of Seq field.
func ( *UpdatesState) () ( int) {
	if  == nil {
		return
	}
	return .Seq
}

// GetUnreadCount returns value of UnreadCount field.
func ( *UpdatesState) () ( int) {
	if  == nil {
		return
	}
	return .UnreadCount
}