Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 20 variants Bool(bool), U8(u8), U16(u16), U32(u32), U64(u64), S8(i8), S16(i16), S32(i32), S64(i64), F32(f32), F64(f64), Char(char), String(String), List { elem_type: ValueType, items: Vec<Value>, }, Option { inner_type: ValueType, value: Option<Box<Value>>, }, Result { ok_type: ValueType, err_type: ValueType, value: Result<Box<Value>, Box<Value>>, }, Record { type_name: String, fields: Vec<(String, Value)>, }, Variant { type_name: String, case_name: String, tag: usize, payload: Vec<Value>, }, Tuple(Vec<Value>), Flags(u64),
}
Expand description

A runtime value that can be passed across package boundaries

Variants§

§

Bool(bool)

§

U8(u8)

§

U16(u16)

§

U32(u32)

§

U64(u64)

§

S8(i8)

§

S16(i16)

§

S32(i32)

§

S64(i64)

§

F32(f32)

§

F64(f64)

§

Char(char)

§

String(String)

§

List

Fields

§elem_type: ValueType
§items: Vec<Value>
§

Option

Fields

§inner_type: ValueType
§value: Option<Box<Value>>
§

Result

Fields

§ok_type: ValueType
§err_type: ValueType
§

Record

Fields

§type_name: String
§fields: Vec<(String, Value)>
§

Variant

Fields

§type_name: String
§case_name: String
§tag: usize
§payload: Vec<Value>
§

Tuple(Vec<Value>)

§

Flags(u64)

Implementations§

Source§

impl Value

Source

pub fn sym(s: impl Into<String>) -> Self

Helper to create a symbol (variant tag 0 with string payload)

Source

pub fn num(n: i64) -> Self

Helper to create a number (variant tag 1 with s64 payload)

Source

pub fn lst(items: Vec<Value>) -> Self

Helper to create a list (variant tag 4 with list payload)

Source

pub fn infer_type(&self) -> ValueType

Infer the ValueType from this Value

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl Display for Value

Source§

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

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

impl From<&str> for Value

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value> + KnownValueType, const N: usize> From<[T; N]> for Value

Source§

fn from(v: [T; N]) -> Self

Converts to this type from the input type.
Source§

impl From<()> for Value

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<Value>> From<(A,)> for Value

Source§

fn from((a): (A,)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<Value>, B: Into<Value>> From<(A, B)> for Value

Source§

fn from((a, b): (A, B)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<Value>, B: Into<Value>, C: Into<Value>> From<(A, B, C)> for Value

Source§

fn from((a, b, c): (A, B, C)) -> Self

Converts to this type from the input type.
Source§

impl<A: Into<Value>, B: Into<Value>, C: Into<Value>, D: Into<Value>> From<(A, B, C, D)> for Value

Source§

fn from((a, b, c, d): (A, B, C, D)) -> Self

Converts to this type from the input type.
Source§

impl<K: Into<Value> + KnownValueType + Ord, V: Into<Value> + KnownValueType> From<BTreeMap<K, V>> for Value

Source§

fn from(v: BTreeMap<K, V>) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value> + KnownValueType + Ord> From<BTreeSet<T>> for Value

Source§

fn from(v: BTreeSet<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value>> From<Box<T>> for Value

Source§

fn from(v: Box<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value> + KnownValueType> From<Option<T>> for Value

Source§

fn from(v: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value> + KnownValueType, E: Into<Value> + KnownValueType> From<Result<T, E>> for Value

Source§

fn from(r: Result<T, E>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value> + KnownValueType> From<Vec<T>> for Value

Source§

fn from(v: Vec<T>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Value

Source§

fn from(v: char) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(v: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(v: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(v: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Value

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromValue for Value

FromValue implementation for Value itself (identity conversion)

Source§

impl GraphCodec for Value

Source§

fn encode_graph(&self, encoder: &mut Encoder) -> Result<u32, AbiError>

Source§

fn decode_graph(decoder: &Decoder<'_>, root: u32) -> Result<Self, AbiError>

Source§

impl KnownValueType for Value

Value is dynamic — its actual ValueType is only known at runtime (Value::infer_type). The compile-time fallback is String, matching the previous PackType for Value behavior. Prefer concrete types when you need accurate static typing.

Source§

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<T: TryFrom<Value, Error = ConversionError>, const N: usize> TryFrom<Value> for [T; N]

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for ()

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<A: TryFrom<Value, Error = ConversionError>> TryFrom<Value> for (A,)

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<A: TryFrom<Value, Error = ConversionError>, B: TryFrom<Value, Error = ConversionError>> TryFrom<Value> for (A, B)

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<A: TryFrom<Value, Error = ConversionError>, B: TryFrom<Value, Error = ConversionError>, C: TryFrom<Value, Error = ConversionError>> TryFrom<Value> for (A, B, C)

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<A: TryFrom<Value, Error = ConversionError>, B: TryFrom<Value, Error = ConversionError>, C: TryFrom<Value, Error = ConversionError>, D: TryFrom<Value, Error = ConversionError>> TryFrom<Value> for (A, B, C, D)

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<K: TryFrom<Value, Error = ConversionError> + Ord, V: TryFrom<Value, Error = ConversionError>> TryFrom<Value> for BTreeMap<K, V>

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: TryFrom<Value, Error = ConversionError> + Ord> TryFrom<Value> for BTreeSet<T>

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for String

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: TryFrom<Value, Error = ConversionError>> TryFrom<Value> for Vec<T>

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for bool

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for char

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for f32

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for f64

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i16

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i32

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i64

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i8

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u16

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u32

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u64

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u8

Source§

type Error = ConversionError

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

fn try_from(v: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.