#[repr(u8)]pub enum IoTypeMetadataKind {
Show 92 variants
Unit = 0,
Bool = 1,
U8 = 2,
U16 = 3,
U32 = 4,
U64 = 5,
U128 = 6,
I8 = 7,
I16 = 8,
I32 = 9,
I64 = 10,
I128 = 11,
Struct = 12,
Struct0 = 13,
Struct1 = 14,
Struct2 = 15,
Struct3 = 16,
Struct4 = 17,
Struct5 = 18,
Struct6 = 19,
Struct7 = 20,
Struct8 = 21,
Struct9 = 22,
Struct10 = 23,
TupleStruct = 24,
TupleStruct1 = 25,
TupleStruct2 = 26,
TupleStruct3 = 27,
TupleStruct4 = 28,
TupleStruct5 = 29,
TupleStruct6 = 30,
TupleStruct7 = 31,
TupleStruct8 = 32,
TupleStruct9 = 33,
TupleStruct10 = 34,
Enum = 35,
Enum1 = 36,
Enum2 = 37,
Enum3 = 38,
Enum4 = 39,
Enum5 = 40,
Enum6 = 41,
Enum7 = 42,
Enum8 = 43,
Enum9 = 44,
Enum10 = 45,
EnumNoFields = 46,
EnumNoFields1 = 47,
EnumNoFields2 = 48,
EnumNoFields3 = 49,
EnumNoFields4 = 50,
EnumNoFields5 = 51,
EnumNoFields6 = 52,
EnumNoFields7 = 53,
EnumNoFields8 = 54,
EnumNoFields9 = 55,
EnumNoFields10 = 56,
Array8b = 57,
Array16b = 58,
Array32b = 59,
ArrayU8x8 = 60,
ArrayU8x16 = 61,
ArrayU8x32 = 62,
ArrayU8x64 = 63,
ArrayU8x128 = 64,
ArrayU8x256 = 65,
ArrayU8x512 = 66,
ArrayU8x1024 = 67,
ArrayU8x2028 = 68,
ArrayU8x4096 = 69,
VariableBytes8b = 70,
VariableBytes16b = 71,
VariableBytes32b = 72,
VariableBytes0 = 73,
VariableBytes512 = 74,
VariableBytes1024 = 75,
VariableBytes2028 = 76,
VariableBytes4096 = 77,
VariableBytes8192 = 78,
VariableBytes16384 = 79,
VariableBytes32768 = 80,
VariableBytes65536 = 81,
VariableBytes131072 = 82,
VariableBytes262144 = 83,
VariableBytes524288 = 84,
VariableBytes1048576 = 85,
VariableElements8b = 86,
VariableElements16b = 87,
VariableElements32b = 88,
VariableElements0 = 89,
Address = 128,
Balance = 129,
}
Expand description
Metadata types contained in TrivialType::METADATA
and IoType::METADATA
.
Metadata encoding consists of this enum variant treated as u8
followed by optional metadata
encoding rules specific to metadata type variant (see variant’s description).
This metadata is enough to fully reconstruct the hierarchy of the type to generate language bindings, auto-generate UI forms, etc.
Variants§
Unit = 0
()
Bool = 1
bool
U8 = 2
u8
U16 = 3
u16
U32 = 4
u32
U64 = 5
u64
U128 = 6
u128
I8 = 7
i8
I16 = 8
i16
I32 = 9
i32
I64 = 10
i64
I128 = 11
i128
Struct = 12
struct S {..}
Structs with named fields are encoded af follows:
- Length of struct name in bytes (u8)
- Struct name as UTF-8 bytes
- Number of fields (u8)
Each field is encoded follows:
- Length of the field name in bytes (u8)
- Field name as UTF-8 bytes
- Recursive metadata of the field’s type
Struct0 = 13
Similar to Self::Struct
, but for exactly 0
struct fields and thus skips number of
fields after struct name
Struct1 = 14
Similar to Self::Struct
, but for exactly 1
struct fields and thus skips number of
fields after struct name
Struct2 = 15
Similar to Self::Struct
, but for exactly 2
struct fields and thus skips number of
fields after struct name
Struct3 = 16
Similar to Self::Struct
, but for exactly 3
struct fields and thus skips number of
fields after struct name
Struct4 = 17
Similar to Self::Struct
, but for exactly 4
struct fields and thus skips number of
fields after struct name
Struct5 = 18
Similar to Self::Struct
, but for exactly 5
struct fields and thus skips number of
fields after struct name
Struct6 = 19
Similar to Self::Struct
, but for exactly 6
struct fields and thus skips number of
fields after struct name
Struct7 = 20
Similar to Self::Struct
, but for exactly 7
struct fields and thus skips number of
fields after struct name
Struct8 = 21
Similar to Self::Struct
, but for exactly 8
struct fields and thus skips number of
fields after struct name
Struct9 = 22
Similar to Self::Struct
, but for exactly 9
struct fields and thus skips number of
fields after struct name
Struct10 = 23
Similar to Self::Struct
, but for exactly 10
struct fields and thus skips number of
fields after struct name
TupleStruct = 24
struct S(..);
Tuple structs are encoded af follows:
- Length of struct name in bytes (u8)
- Struct name as UTF-8 bytes
- Number of fields (u8)
Each field is encoded follows:
- Recursive metadata of the field’s type
TupleStruct1 = 25
Similar to Self::TupleStruct
, but for exactly 1
struct fields and thus skips number of
fields after struct name
TupleStruct2 = 26
Similar to Self::TupleStruct
, but for exactly 2
struct fields and thus skips number of
fields after struct name
TupleStruct3 = 27
Similar to Self::TupleStruct
, but for exactly 3
struct fields and thus skips number of
fields after struct name
TupleStruct4 = 28
Similar to Self::TupleStruct
, but for exactly 4
struct fields and thus skips number of
fields after struct name
TupleStruct5 = 29
Similar to Self::TupleStruct
, but for exactly 5
struct fields and thus skips number of
fields after struct name
TupleStruct6 = 30
Similar to Self::TupleStruct
, but for exactly 6
struct fields and thus skips number of
fields after struct name
TupleStruct7 = 31
Similar to Self::TupleStruct
, but for exactly 7
struct fields and thus skips number of
fields after struct name
TupleStruct8 = 32
Similar to Self::TupleStruct
, but for exactly 8
struct fields and thus skips number of
fields after struct name
TupleStruct9 = 33
Similar to Self::TupleStruct
, but for exactly 9
struct fields and thus skips number of
fields after struct name
TupleStruct10 = 34
Similar to Self::TupleStruct
, but for exactly 10
struct fields and thus skips number
of fields after struct name
Enum = 35
enum E { Variant {..} }
Enums with variants that have fields are encoded as follows:
- Length of enum name in bytes (u8)
- Enum name as UTF-8 bytes
- Number of variants (u8)
- Each enum variant as if it was a struct with fields, see
Self::Struct
for details
Enum1 = 36
Similar to Self::Enum
, but for exactly 1
enum variants and thus skips number of
variants after enum name
Enum2 = 37
Similar to Self::Enum
, but for exactly 2
enum variants and thus skips number of
variants after enum name
Enum3 = 38
Similar to Self::Enum
, but for exactly 3
enum variants and thus skips number of
variants after enum name
Enum4 = 39
Similar to Self::Enum
, but for exactly 4
enum variants and thus skips number of
variants after enum name
Enum5 = 40
Similar to Self::Enum
, but for exactly 5
enum variants and thus skips number of
variants after enum name
Enum6 = 41
Similar to Self::Enum
, but for exactly 6
enum variants and thus skips number of
variants after enum name
Enum7 = 42
Similar to Self::Enum
, but for exactly 7
enum variants and thus skips number of
variants after enum name
Enum8 = 43
Similar to Self::Enum
, but for exactly 8
enum variants and thus skips number of
variants after enum name
Enum9 = 44
Similar to Self::Enum
, but for exactly 9
enum variants and thus skips number of
variants after enum name
Enum10 = 45
Similar to Self::Enum
, but for exactly 10
enum variants and thus skips number of
variants after enum name
EnumNoFields = 46
enum E { A, B }
Enums with variants that have no fields are encoded as follows:
- Length of enum name in bytes (u8)
- Enum name as UTF-8 bytes
- Number of variants (u8)
Each enum variant is encoded follows:
- Length of the variant name in bytes (u8)
- Variant name as UTF-8 bytes
EnumNoFields1 = 47
Similar to Self::EnumNoFields
, but for exactly 1
enum variants and thus skips number
of variants after enum name
EnumNoFields2 = 48
Similar to Self::EnumNoFields
, but for exactly 2
enum variants and thus skips number
of variants after enum name
EnumNoFields3 = 49
Similar to Self::EnumNoFields
, but for exactly 3
enum variants and thus skips number
of variants after enum name
EnumNoFields4 = 50
Similar to Self::EnumNoFields
, but for exactly 4
enum variants and thus skips number
of variants after enum name
EnumNoFields5 = 51
Similar to Self::EnumNoFields
, but for exactly 5
enum variants and thus skips number
of variants after enum name
EnumNoFields6 = 52
Similar to Self::EnumNoFields
, but for exactly 6
enum variants and thus skips number
of variants after enum name
EnumNoFields7 = 53
Similar to Self::EnumNoFields
, but for exactly 7
enum variants and thus skips number
of variants after enum name
EnumNoFields8 = 54
Similar to Self::EnumNoFields
, but for exactly 8
enum variants and thus skips number
of variants after enum name
EnumNoFields9 = 55
Similar to Self::EnumNoFields
, but for exactly 9
enum variants and thus skips number
of variants after enum name
EnumNoFields10 = 56
Similar to Self::EnumNoFields
, but for exactly 10
enum variants and thus skips number
of variants after enum name
Array8b = 57
Array [T; N]
with up to 2^8 elements.
Arrays with up to 2^8 encoded as follows:
- 1 byte number of elements
- Recursive metadata of contained type
Array16b = 58
Array [T; N]
with up to 2^16 elements.
Arrays with up to 2^16 encoded as follows:
- 2 bytes number of elements (little-endian)
- Recursive metadata of contained type
Array32b = 59
Array [T; N]
with up to 2^32 elements.
Arrays with up to 2^32 encoded as follows:
- 4 bytes number of elements (little-endian)
- Recursive metadata of contained type
ArrayU8x8 = 60
Compact alias for [u8; 8]
ArrayU8x16 = 61
Compact alias for [u8; 16]
ArrayU8x32 = 62
Compact alias for [u8; 32]
ArrayU8x64 = 63
Compact alias for [u8; 64]
ArrayU8x128 = 64
Compact alias for [u8; 128]
ArrayU8x256 = 65
Compact alias for [u8; 256]
ArrayU8x512 = 66
Compact alias for [u8; 512]
ArrayU8x1024 = 67
Compact alias for [u8; 1024]
ArrayU8x2028 = 68
Compact alias for [u8; 2028]
ArrayU8x4096 = 69
Compact alias for [u8; 4096]
VariableBytes8b = 70
Variable bytes with up to 2^8 bytes recommended allocation.
Variable bytes with up to 2^8 bytes encoded as follows:
- 1 byte recommended allocation in bytes
VariableBytes16b = 71
Variable bytes with up to 2^16 bytes recommended allocation.
Variable bytes with up to 2^16 bytes encoded as follows:
- 2 bytes recommended allocation in bytes (little-endian)
VariableBytes32b = 72
Variable bytes with up to 2^32 bytes recommended allocation.
Variable bytes with up to 2^8 bytes encoded as follows:
- 4 bytes recommended allocation in bytes (little-endian)
VariableBytes0 = 73
Compact alias VariableBytes<0>
VariableBytes512 = 74
Compact alias VariableBytes<512>
VariableBytes1024 = 75
Compact alias VariableBytes<1024>
VariableBytes2028 = 76
Compact alias VariableBytes<2028>
VariableBytes4096 = 77
Compact alias VariableBytes<4096>
VariableBytes8192 = 78
Compact alias VariableBytes<8192>
VariableBytes16384 = 79
Compact alias VariableBytes<16384>
VariableBytes32768 = 80
Compact alias VariableBytes<32768>
VariableBytes65536 = 81
Compact alias VariableBytes<65536>
VariableBytes131072 = 82
Compact alias VariableBytes<131072>
VariableBytes262144 = 83
Compact alias VariableBytes<262144>
VariableBytes524288 = 84
Compact alias VariableBytes<524288>
VariableBytes1048576 = 85
Compact alias VariableBytes<1048576>
VariableElements8b = 86
Variable elements with up to 2^8 elements recommended allocation.
Variable elements with up to 2^8 elements encoded as follows:
- 1 byte recommended allocation in bytes
VariableElements16b = 87
Variable elements with up to 2^16 elements recommended allocation.
Variable elements with up to 2^16 elements encoded as follows:
- 2 bytes recommended allocation in elements (little-endian)
VariableElements32b = 88
Variable elements with up to 2^32 elements recommended allocation.
Variable elements with up to 2^8 elements encoded as follows:
- 4 bytes recommended allocation in elements (little-endian)
VariableElements0 = 89
Compact alias VariableElements<0, T>
Address = 128
Address of a contract.
Internally u128
with 8
byte alignment
Balance = 129
Balance of a token.
Internally u128
with 8
byte alignment
Implementations§
Source§impl IoTypeMetadataKind
impl IoTypeMetadataKind
Sourcepub const fn try_from_u8(byte: u8) -> Option<Self>
pub const fn try_from_u8(byte: u8) -> Option<Self>
Try to create an instance from its u8
representation
Sourcepub const fn compact<'i, 'o>(
input: &'i [u8],
output: &'o mut [u8],
) -> Option<(&'i [u8], &'o mut [u8])>
pub const fn compact<'i, 'o>( input: &'i [u8], output: &'o mut [u8], ) -> Option<(&'i [u8], &'o mut [u8])>
Produce compact metadata.
Compact metadata retains the shape, but throws some details. Specifically, the following transformations are applied to metadata:
- Struct names, enum names and enum variant names are removed (replaced with zero bytes names)
- Structs and enum variants are turned into tuple variants (removing field names)
This is typically called by higher-level functions and doesn’t need to be used directly.
This function takes an input
that starts with metadata defined in IoTypeMetadataKind
and output
where compact metadata must be written. Since input might have other data past
the data structure to be processed, the remainder of input and output are returned to the
caller.
Unexpected metadata kind results in None
being returned.
Sourcepub const fn type_name(metadata: &[u8]) -> Option<&[u8]>
pub const fn type_name(metadata: &[u8]) -> Option<&[u8]>
Decode type name.
Expected to be UTF-8, but must be parsed before printed as text, which is somewhat costly.
Sourcepub const fn type_details(metadata: &[u8]) -> Option<(IoTypeDetails, &[u8])>
pub const fn type_details(metadata: &[u8]) -> Option<(IoTypeDetails, &[u8])>
Decode type, return its recommended capacity that should be allocated by the host.
If actual data is larger, it will be passed down to the guest as it is, if smaller than host should allocate recommended capacity for guest anyway.
Returns type details and whatever slice of bytes from input
that is left after
type decoding.
Trait Implementations§
Source§impl Clone for IoTypeMetadataKind
impl Clone for IoTypeMetadataKind
Source§fn clone(&self) -> IoTypeMetadataKind
fn clone(&self) -> IoTypeMetadataKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more