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

// DefaultHistoryTTL represents TL type `defaultHistoryTTL#43b46b20`.
// Contains info about the default value of the Time-To-Live setting, applied to all new
// chats.
//
// See https://core.telegram.org/constructor/defaultHistoryTTL for reference.
type DefaultHistoryTTL struct {
	// Time-To-Live setting applied to all new chats.
	Period int
}

// DefaultHistoryTTLTypeID is TL type id of DefaultHistoryTTL.
const DefaultHistoryTTLTypeID = 0x43b46b20

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

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

	return true
}

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

// FillFrom fills DefaultHistoryTTL from given interface.
func ( *DefaultHistoryTTL) ( interface {
	() ( int)
}) {
	.Period = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *DefaultHistoryTTL) () tdp.Type {
	 := tdp.Type{
		Name: "defaultHistoryTTL",
		ID:   DefaultHistoryTTLTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Period",
			SchemaName: "period",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *DefaultHistoryTTL) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode defaultHistoryTTL#43b46b20 as nil")
	}
	.PutID(DefaultHistoryTTLTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DefaultHistoryTTL) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode defaultHistoryTTL#43b46b20 as nil")
	}
	.PutInt(.Period)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DefaultHistoryTTL) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode defaultHistoryTTL#43b46b20 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode defaultHistoryTTL#43b46b20: field period: %w", )
		}
		.Period = 
	}
	return nil
}

// GetPeriod returns value of Period field.
func ( *DefaultHistoryTTL) () ( int) {
	if  == nil {
		return
	}
	return .Period
}