#[repr(u8)]pub enum Tag {
Show 33 variants
False = 0,
True = 1,
Void = 2,
Error = 3,
U32Val = 4,
I32Val = 5,
U64Small = 6,
I64Small = 7,
TimepointSmall = 8,
DurationSmall = 9,
U128Small = 10,
I128Small = 11,
U256Small = 12,
I256Small = 13,
SymbolSmall = 14,
SmallCodeUpperBound = 15,
ObjectCodeLowerBound = 63,
U64Object = 64,
I64Object = 65,
TimepointObject = 66,
DurationObject = 67,
U128Object = 68,
I128Object = 69,
U256Object = 70,
I256Object = 71,
BytesObject = 72,
StringObject = 73,
SymbolObject = 74,
VecObject = 75,
MapObject = 76,
AddressObject = 77,
ObjectCodeUpperBound = 78,
Bad = 127,
}
Expand description
Code values for the 8 tag
bits in the bit-packed representation
of Val. These don’t coincide with tag numbers in the SCVal XDR
but cover all those cases as well as some optimized refinements for
special cases (boolean true and false, small-value forms).
Variants§
False = 0
Tag for a Val that encodes bool false
. The bool type is refined to
two single-value subtypes in order for each tag number to coincide with
the WASM encoding of a boolean.
True = 1
Void = 2
Tag for a Val that is empty/absent (eg. void, null, nil, undefined, None)
Error = 3
Tag for a Val that is contains an error code.
U32Val = 4
I32Val = 5
U64Small = 6
I64Small = 7
TimepointSmall = 8
DurationSmall = 9
U128Small = 10
I128Small = 11
U256Small = 12
I256Small = 13
SymbolSmall = 14
Tag for a Val that contains up to 9 character symbols.
SmallCodeUpperBound = 15
Code delimiting the upper boundary of “small” types.
ObjectCodeLowerBound = 63
Tag reserved to indicate boundary between tags for “small” types with their payload packed into the remaining 56 bits of the Val and “object” types that are stored as host objects and referenced by Object handle.
U64Object = 64
I64Object = 65
TimepointObject = 66
Tag for a Val that refers to a host-side u64 number encoding a time-point (a count of seconds since the Unix epoch, Jan 1 1970 UTC).
DurationObject = 67
U128Object = 68
I128Object = 69
U256Object = 70
I256Object = 71
BytesObject = 72
Tag for a Val that refers to a host-side byte array.
StringObject = 73
Tag for a Val that refers to a host-side string.
SymbolObject = 74
VecObject = 75
MapObject = 76
AddressObject = 77
Tag for a Val that refers to a host-side contract address.
ObjectCodeUpperBound = 78
Code delimiting the upper boundary of “object” types.
Bad = 127
Code reserved to indicate mis-tagged Val
s.
Implementations§
Source§impl Tag
impl Tag
pub const fn val_mask() -> i64
pub fn val_const(&self) -> i64
pub const fn is_object(self) -> bool
pub const fn from_u8(tag: u8) -> Tag
Sourcepub const fn get_scval_type(&self) -> Option<ScValType>
pub const fn get_scval_type(&self) -> Option<ScValType>
Get the ScValType of the XDR type that corresponds to this tag.
For use in the Host::obj_cmp
comparison function so that comparison
based on tags can be done identically to the ScVal
type.
Returns None
for Tag::Bad
, and for the three marker tags
SmallCodeUpperBound
, ObjectCodeLowerBound
, ObjectCodeUpperBound
.