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

// AccountAuthorizations represents TL type `account.authorizations#4bff8ea0`.
// Logged-in sessions
//
// See https://core.telegram.org/constructor/account.authorizations for reference.
type AccountAuthorizations struct {
	// Time-to-live of session
	AuthorizationTTLDays int
	// Logged-in sessions
	Authorizations []Authorization
}

// AccountAuthorizationsTypeID is TL type id of AccountAuthorizations.
const AccountAuthorizationsTypeID = 0x4bff8ea0

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

func ( *AccountAuthorizations) () bool {
	if  == nil {
		return true
	}
	if !(.AuthorizationTTLDays == 0) {
		return false
	}
	if !(.Authorizations == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountAuthorizations from given interface.
func ( *AccountAuthorizations) ( interface {
	() ( int)
	() ( []Authorization)
}) {
	.AuthorizationTTLDays = .()
	.Authorizations = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountAuthorizations) () string {
	return "account.authorizations"
}

// TypeInfo returns info about TL type.
func ( *AccountAuthorizations) () tdp.Type {
	 := tdp.Type{
		Name: "account.authorizations",
		ID:   AccountAuthorizationsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AuthorizationTTLDays",
			SchemaName: "authorization_ttl_days",
		},
		{
			Name:       "Authorizations",
			SchemaName: "authorizations",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountAuthorizations) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.authorizations#4bff8ea0 as nil")
	}
	.PutID(AccountAuthorizationsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountAuthorizations) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.authorizations#4bff8ea0 as nil")
	}
	.PutInt(.AuthorizationTTLDays)
	.PutVectorHeader(len(.Authorizations))
	for ,  := range .Authorizations {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode account.authorizations#4bff8ea0: field authorizations element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountAuthorizations) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.authorizations#4bff8ea0 to nil")
	}
	if  := .ConsumeID(AccountAuthorizationsTypeID);  != nil {
		return fmt.Errorf("unable to decode account.authorizations#4bff8ea0: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountAuthorizations) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.authorizations#4bff8ea0 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode account.authorizations#4bff8ea0: field authorization_ttl_days: %w", )
		}
		.AuthorizationTTLDays = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.authorizations#4bff8ea0: field authorizations: %w", )
		}

		if  > 0 {
			.Authorizations = make([]Authorization, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  Authorization
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.authorizations#4bff8ea0: field authorizations: %w", )
			}
			.Authorizations = append(.Authorizations, )
		}
	}
	return nil
}

// GetAuthorizationTTLDays returns value of AuthorizationTTLDays field.
func ( *AccountAuthorizations) () ( int) {
	if  == nil {
		return
	}
	return .AuthorizationTTLDays
}

// GetAuthorizations returns value of Authorizations field.
func ( *AccountAuthorizations) () ( []Authorization) {
	if  == nil {
		return
	}
	return .Authorizations
}