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

// AccountPasskeys represents TL type `account.passkeys#f8e0aa1c`.
// List of passkeys »¹ associated to the current account.
//
// Links:
//  1. https://core.telegram.org/api/passkeys#list-passkeys
//
// See https://core.telegram.org/constructor/account.passkeys for reference.
type AccountPasskeys struct {
	// List of passkeys that can be used to log into the current account
	Passkeys []Passkey
}

// AccountPasskeysTypeID is TL type id of AccountPasskeys.
const AccountPasskeysTypeID = 0xf8e0aa1c

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

func ( *AccountPasskeys) () bool {
	if  == nil {
		return true
	}
	if !(.Passkeys == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountPasskeys from given interface.
func ( *AccountPasskeys) ( interface {
	() ( []Passkey)
}) {
	.Passkeys = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountPasskeys) () tdp.Type {
	 := tdp.Type{
		Name: "account.passkeys",
		ID:   AccountPasskeysTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Passkeys",
			SchemaName: "passkeys",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountPasskeys) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.passkeys#f8e0aa1c as nil")
	}
	.PutID(AccountPasskeysTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountPasskeys) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.passkeys#f8e0aa1c to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.passkeys#f8e0aa1c: field passkeys: %w", )
		}

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

// GetPasskeys returns value of Passkeys field.
func ( *AccountPasskeys) () ( []Passkey) {
	if  == nil {
		return
	}
	return .Passkeys
}