Module std::type_name
Functionality for converting Move types into values. Use with care!
- Struct TypeName
- Constants
- Function with_defining_ids
- Function with_original_ids
- Function defining_id
- Function original_id
- Function is_primitive
- Function as_string
- Function address_string
- Function module_string
- Function datatype_string
- Function into_string
- Function get
- Function get_with_original_ids
- Function borrow_string
- Function get_address
- Function get_module
use std::address;
use std::ascii;
use std::option;
use std::vector;
Struct TypeName
public struct TypeName has copy, drop, store
Fields
- name: std::ascii::String
-
String representation of the type. All types are represented
using their source syntax:
"u8", "u64", "bool", "address", "vector", and so on for primitive types.
Struct types are represented as fully qualified type names; e.g. 00000000000000000000000000000001::string::String or 0000000000000000000000000000000a::module_name1::type_name1<0000000000000000000000000000000a::module_name2::type_name2<u64>> Addresses are hex-encoded lowercase values of length ADDRESS_LENGTH (16, 20, or 32 depending on the Move platform)
Constants
ASCII Character code for the : (colon) symbol.
const ASCII_COLON: u8 = 58;
ASCII Character code for the < (less than) symbol.
const ASCII_LESS_THAN: u8 = 60;
ASCII Character code for the v (lowercase v) symbol.
const ASCII_V: u8 = 118;
ASCII Character code for the e (lowercase e) symbol.
const ASCII_E: u8 = 101;
ASCII Character code for the c (lowercase c) symbol.
const ASCII_C: u8 = 99;
ASCII Character code for the t (lowercase t) symbol.
const ASCII_T: u8 = 116;
ASCII Character code for the o (lowercase o) symbol.
const ASCII_O: u8 = 111;
ASCII Character code for the r (lowercase r) symbol.
const ASCII_R: u8 = 114;
The type is not from a package/module. It is a primitive type.
const ENonModuleType: u64 = 0;
Function with_defining_ids
Return a value representation of the type T. Package IDs that appear in fully qualified type names in the output from this function are defining IDs (the ID of the package in storage that first introduced the type).
public fun with_defining_ids<T>(): std::type_name::TypeName
Function with_original_ids
Return a value representation of the type T. Package IDs that appear in fully qualified type names in the output from this function are original IDs (the ID of the first version of the package, even if the type in question was introduced in a later upgrade).
public fun with_original_ids<T>(): std::type_name::TypeName
Function defining_id
Like with_defining_ids, this accesses the package ID that original defined the type T.
public fun defining_id<T>(): address
Function original_id
Like with_original_ids, this accesses the original ID of the package that defines type T, even if the type was introduced in a later version of the package.
public fun original_id<T>(): address
Function is_primitive
Returns true iff the TypeName represents a primitive type, i.e. one of u8, u16, u32, u64, u128, u256, bool, address, vector.
public fun is_primitive(self: &std::type_name::TypeName): bool
Function as_string
Get the String representation of self
public fun as_string(self: &std::type_name::TypeName): &std::ascii::String
Function address_string
Get Address string (Base16 encoded), first part of the TypeName.
Aborts if given a primitive type.
public fun address_string(self: &std::type_name::TypeName): std::ascii::String
Function module_string
Get name of the module.
Aborts if given a primitive type.
public fun module_string(self: &std::type_name::TypeName): std::ascii::String
Function datatype_string
Get name of the datatype (struct or enum).
Aborts if given a primitive type.
public fun datatype_string(self: &std::type_name::TypeName): std::ascii::String
Function into_string
Convert self into its inner String
public fun into_string(self: std::type_name::TypeName): std::ascii::String
Function get
public fun get<T>(): std::type_name::TypeName
Function get_with_original_ids
public fun get_with_original_ids<T>(): std::type_name::TypeName
Function borrow_string
public fun borrow_string(self: &std::type_name::TypeName): &std::ascii::String
Function get_address
public fun get_address(self: &std::type_name::TypeName): std::ascii::String
Function get_module
public fun get_module(self: &std::type_name::TypeName): std::ascii::String