soroban_env_common

Enum Tag

Source
#[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

Tag for a Val that encodes bool true.

§

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

Tag for a Val that contains a u32 number.

§

I32Val = 5

Tag for a Val that contains an i32 number.

§

U64Small = 6

Tag for a Val that contains a u64 small enough to fit in 56 bits.

§

I64Small = 7

Tag for a Val that contains an i64 small enough to fit in 56 bits.

§

TimepointSmall = 8

Tag for a Val that contains a u64 timepoint small enough to fit in 56 bits.

§

DurationSmall = 9

Tag for a Val that contains a u64 duration small enough to fit in 56 bits.

§

U128Small = 10

Tag for a Val that contains a u128 small enough to fit in 56 bits.

§

I128Small = 11

Tag for a Val that contains an i128 small enough to fit in 56 bits.

§

U256Small = 12

Tag for a Val that contains a u256 small enough to fit in 56 bits.

§

I256Small = 13

Tag for a Val that contains an i256 small enough to fit in 56 bits.

§

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

Tag for a Val that refers to a host-side u64 number.

§

I64Object = 65

Tag for a Val that refers to a host-side i64 number.

§

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

Tag for a Val that refers to a host-side i64 number encoding a duration (a count of seconds).

§

U128Object = 68

Tag for a Val that refers to a host-side u128 number.

§

I128Object = 69

Tag for a Val that refers to a host-side i128 number.

§

U256Object = 70

Tag for a Val that refers to a host-side u256 number.

§

I256Object = 71

Tag for a Val that refers to a host-side i256 number.

§

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

Tag for a Val that refers to a host-side symbol (see Symbol).

§

VecObject = 75

Tag for a Val that refers to a host-side vector of Vals.

§

MapObject = 76

Tag for a Val that refers to a host-side map from Vals to Vals.

§

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 Vals.

Implementations§

Source§

impl Tag

Source

pub const fn val_mask() -> i64

Source

pub fn val_const(&self) -> i64

Source

pub const fn is_object(self) -> bool

Source

pub const fn from_u8(tag: u8) -> Tag

Source

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.

Trait Implementations§

Source§

impl Clone for Tag

Source§

fn clone(&self) -> Tag

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Tag

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Tag

Source§

fn cmp(&self, other: &Tag) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Tag

Source§

fn eq(&self, other: &Tag) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Tag

Source§

fn partial_cmp(&self, other: &Tag) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Tag

Source§

impl Eq for Tag

Source§

impl StructuralPartialEq for Tag

Auto Trait Implementations§

§

impl Freeze for Tag

§

impl RefUnwindSafe for Tag

§

impl Send for Tag

§

impl Sync for Tag

§

impl Unpin for Tag

§

impl UnwindSafe for Tag

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T, C> Compare<&T> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare(&self, a: &&T, b: &&T) -> Result<Ordering, <C as Compare<&T>>::Error>

Source§

impl<T, U, E, C> Compare<(T, U)> for C
where C: Compare<T, Error = E, Error = E> + Compare<U>,

Source§

type Error = E

Source§

fn compare( &self, a: &(T, U), b: &(T, U), ) -> Result<Ordering, <C as Compare<(T, U)>>::Error>

Source§

impl<T, U, V, E, C> Compare<(T, U, V)> for C
where C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,

Source§

impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
where C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,

Source§

impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
where C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,

Source§

impl<T, C> Compare<Box<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Box<T>, b: &Box<T>, ) -> Result<Ordering, <C as Compare<Box<T>>>::Error>

Source§

impl<T, C> Compare<Option<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Option<T>, b: &Option<T>, ) -> Result<Ordering, <C as Compare<Option<T>>>::Error>

Source§

impl<T, C> Compare<Rc<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Rc<T>, b: &Rc<T>, ) -> Result<Ordering, <C as Compare<Rc<T>>>::Error>

Source§

impl<T, C> Compare<Vec<T>> for C
where C: Compare<T>,

Source§

type Error = <C as Compare<T>>::Error

Source§

fn compare( &self, a: &Vec<T>, b: &Vec<T>, ) -> Result<Ordering, <C as Compare<Vec<T>>>::Error>

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<E, T, U> TryIntoVal<E, T> for U
where E: Env, T: TryFromVal<E, U>,

Source§

type Error = <T as TryFromVal<E, U>>::Error

Source§

fn try_into_val(&self, env: &E) -> Result<T, <U as TryIntoVal<E, T>>::Error>