type_info - [mainnet]
use 0x1::bcs;use 0x1::error;use 0x1::features;use 0x1::string;
Constants
const E_NATIVE_FUN_NOT_AVAILABLE: u64 = 1;
Structs
TypeInfo
struct TypeInfo has copy, drop, store
Functions
account_address
public fun account_address(self: &type_info::TypeInfo): address
Implementation
public fun account_address(self: &TypeInfo): address { self.account_address}
module_name
public fun module_name(self: &type_info::TypeInfo): vector<u8>
Implementation
public fun module_name(self: &TypeInfo): vector<u8> { self.module_name}
struct_name
public fun struct_name(self: &type_info::TypeInfo): vector<u8>
Implementation
public fun struct_name(self: &TypeInfo): vector<u8> { self.struct_name}
chain_id
Returns the current chain ID, mirroring what aptos_framework::chain_id::get()
would return, except in #[test]
functions, where this will always return 4u8
as the chain ID, whereas aptos_framework::chain_id::get()
will
return whichever ID was passed to aptos_framework::chain_id::initialize_for_test()
.
public fun chain_id(): u8
Implementation
public fun chain_id(): u8 { if (!features::aptos_stdlib_chain_id_enabled()) { abort(std::error::invalid_state(E_NATIVE_FUN_NOT_AVAILABLE)) };
chain_id_internal()}
type_of
Return the TypeInfo
struct containing for the type T
.
public fun type_of<T>(): type_info::TypeInfo
Implementation
public native fun type_of<T>(): TypeInfo;
type_name
Return the human readable string for the type, including the address, module name, and any type arguments. Example: 0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin> Or: 0x1::table::Table<0x1::string::String, 0x1::string::String>
public fun type_name<T>(): string::String
Implementation
public native fun type_name<T>(): String;
chain_id_internal
fun chain_id_internal(): u8
Implementation
native fun chain_id_internal(): u8;
size_of_val
Return the BCS size, in bytes, of value at val_ref
.
See the BCS spec
See test_size_of_val()
for an analysis of common types and
nesting patterns, as well as test_size_of_val_vectors()
for an
analysis of vector size dynamism.
public fun size_of_val<T>(val_ref: &T): u64
Implementation
public fun size_of_val<T>(val_ref: &T): u64 { bcs::serialized_size(val_ref)}
Specification
native fun spec_is_struct<T>(): bool;
chain_id
public fun chain_id(): u8
aborts_if !features::spec_is_enabled(features::APTOS_STD_CHAIN_ID_NATIVES);ensures result == spec_chain_id_internal();
type_of
public fun type_of<T>(): type_info::TypeInfo
type_name
public fun type_name<T>(): string::String
chain_id_internal
fun chain_id_internal(): u8
pragma opaque;aborts_if false;ensures result == spec_chain_id_internal();
fun spec_chain_id_internal(): u8;
fun spec_size_of_val<T>(val_ref: T): u64 { len(std::bcs::serialize(val_ref))}
size_of_val
public fun size_of_val<T>(val_ref: &T): u64
ensures result == spec_size_of_val<T>(val_ref);