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

// HelpConfigSimple represents TL type `help.configSimple#5a592a6c`.
//
// See https://core.telegram.org/constructor/help.configSimple for reference.
type HelpConfigSimple struct {
	// Date field of HelpConfigSimple.
	Date int
	// Expires field of HelpConfigSimple.
	Expires int
	// Rules field of HelpConfigSimple.
	Rules []AccessPointRule
}

// HelpConfigSimpleTypeID is TL type id of HelpConfigSimple.
const HelpConfigSimpleTypeID = 0x5a592a6c

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

func ( *HelpConfigSimple) () bool {
	if  == nil {
		return true
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Expires == 0) {
		return false
	}
	if !(.Rules == nil) {
		return false
	}

	return true
}

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

// FillFrom fills HelpConfigSimple from given interface.
func ( *HelpConfigSimple) ( interface {
	() ( int)
	() ( int)
	() ( []AccessPointRule)
}) {
	.Date = .()
	.Expires = .()
	.Rules = .()
}

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

// TypeName returns name of type in TL schema.
func (*HelpConfigSimple) () string {
	return "help.configSimple"
}

// TypeInfo returns info about TL type.
func ( *HelpConfigSimple) () tdp.Type {
	 := tdp.Type{
		Name: "help.configSimple",
		ID:   HelpConfigSimpleTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Expires",
			SchemaName: "expires",
		},
		{
			Name:       "Rules",
			SchemaName: "rules",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpConfigSimple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.configSimple#5a592a6c as nil")
	}
	.PutID(HelpConfigSimpleTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpConfigSimple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.configSimple#5a592a6c as nil")
	}
	.PutInt(.Date)
	.PutInt(.Expires)
	.PutInt(len(.Rules))
	for ,  := range .Rules {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode help.configSimple#5a592a6c: field rules element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *HelpConfigSimple) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.configSimple#5a592a6c to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.configSimple#5a592a6c: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.configSimple#5a592a6c: field expires: %w", )
		}
		.Expires = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.configSimple#5a592a6c: field rules: %w", )
		}

		if  > 0 {
			.Rules = make([]AccessPointRule, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  AccessPointRule
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode help.configSimple#5a592a6c: field rules: %w", )
			}
			.Rules = append(.Rules, )
		}
	}
	return nil
}

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

// GetExpires returns value of Expires field.
func ( *HelpConfigSimple) () ( int) {
	if  == nil {
		return
	}
	return .Expires
}

// GetRules returns value of Rules field.
func ( *HelpConfigSimple) () ( []AccessPointRule) {
	if  == nil {
		return
	}
	return .Rules
}