pub enum Value {
Show 34 variants
Bool(bool),
Byte(u8),
Char(char),
Integer(i64),
Float(f64),
Type(Type),
Ordering(Ordering),
String(Shared<String>),
Bytes(Shared<Bytes>),
Vec(Shared<Vec>),
EmptyTuple,
Tuple(Shared<OwnedTuple>),
Object(Shared<Object>),
RangeFrom(Shared<RangeFrom>),
RangeFull(Shared<RangeFull>),
RangeInclusive(Shared<RangeInclusive>),
RangeToInclusive(Shared<RangeToInclusive>),
RangeTo(Shared<RangeTo>),
Range(Shared<Range>),
ControlFlow(Shared<ControlFlow>),
Future(Shared<Future>),
Stream(Shared<Stream<Vm>>),
Generator(Shared<Generator<Vm>>),
GeneratorState(Shared<GeneratorState>),
Option(Shared<Option<Value>>),
Result(Shared<Result<Value, Value>>),
EmptyStruct(Shared<EmptyStruct>),
TupleStruct(Shared<TupleStruct>),
Struct(Shared<Struct>),
Variant(Shared<Variant>),
Function(Shared<Function>),
Format(Shared<Format>),
Iterator(Shared<Iterator>),
Any(Shared<AnyObj>),
}
Expand description
An entry on the stack.
Variants§
Bool(bool)
A boolean.
Byte(u8)
A single byte.
Char(char)
A character.
Integer(i64)
A number.
Float(f64)
A float.
Type(Type)
A type hash. Describes a type in the virtual machine.
Ordering(Ordering)
Ordering.
String(Shared<String>)
A UTF-8 string.
Bytes(Shared<Bytes>)
A byte string.
Vec(Shared<Vec>)
A vector containing any values.
EmptyTuple
The unit value.
Tuple(Shared<OwnedTuple>)
A tuple.
Object(Shared<Object>)
An object.
RangeFrom(Shared<RangeFrom>)
A range start..
RangeFull(Shared<RangeFull>)
A full range ..
RangeInclusive(Shared<RangeInclusive>)
A full range start..=end
RangeToInclusive(Shared<RangeToInclusive>)
A full range ..=end
RangeTo(Shared<RangeTo>)
A full range ..end
Range(Shared<Range>)
A range start..end
.
ControlFlow(Shared<ControlFlow>)
A control flow indicator.
Future(Shared<Future>)
A stored future.
Stream(Shared<Stream<Vm>>)
A Stream.
Generator(Shared<Generator<Vm>>)
A stored generator.
GeneratorState(Shared<GeneratorState>)
Generator state.
Option(Shared<Option<Value>>)
An empty value indicating nothing.
Result(Shared<Result<Value, Value>>)
A stored result in a slot.
EmptyStruct(Shared<EmptyStruct>)
An struct with a well-defined type.
TupleStruct(Shared<TupleStruct>)
A tuple with a well-defined type.
Struct(Shared<Struct>)
An struct with a well-defined type.
Variant(Shared<Variant>)
The variant of an enum.
Function(Shared<Function>)
A stored function pointer.
Format(Shared<Format>)
A value being formatted.
Iterator(Shared<Iterator>)
An iterator.
Any(Shared<AnyObj>)
An opaque value that can be downcasted.
Implementations§
Source§impl Value
impl Value
Sourcepub fn string_display(&self, f: &mut Formatter) -> VmResult<()>
pub fn string_display(&self, f: &mut Formatter) -> VmResult<()>
Format the value using the Protocol::STRING_DISPLAY protocol.
Requires a work buffer buf
which will be used in case the value
provided requires out-of-line formatting. This must be cleared between
calls and can be re-used.
You must use Vm::with to specify which virtual machine this function is called inside.
§Panics
This function will panic if called outside of a virtual machine.
Sourcepub fn string_debug(&self, f: &mut Formatter) -> VmResult<()>
pub fn string_debug(&self, f: &mut Formatter) -> VmResult<()>
Debug format the value using the STRING_DEBUG
protocol.
You must use Vm::with to specify which virtual machine this function is called inside.
§Panics
This function will panic if called outside of a virtual machine.
Sourcepub fn into_iter(self) -> VmResult<Iterator>
pub fn into_iter(self) -> VmResult<Iterator>
Convert value into an iterator using the Protocol::INTO_ITER
protocol.
You must use Vm::with to specify which virtual machine this function is called inside.
§Errors
This function will error if called outside of a virtual machine context.
Sourcepub fn into_future(self) -> VmResult<Shared<Future>>
pub fn into_future(self) -> VmResult<Shared<Future>>
Coerce into a future, or convert into a future using the Protocol::INTO_FUTURE protocol.
You must use Vm::with to specify which virtual machine this function is called inside.
§Errors
This function errors in case the provided type cannot be converted into
a future without the use of a Vm
and one is not provided through the
environment.
Sourcepub fn into_type_name(self) -> VmResult<String>
pub fn into_type_name(self) -> VmResult<String>
Retrieves a human readable type name for the current value.
You must use Vm::with to specify which virtual machine this function is called inside.
§Errors
This function errors in case the provided type cannot be converted into
a name without the use of a Vm
and one is not provided through the
environment.
Sourcepub fn empty_struct(rtti: Arc<Rtti>) -> VmResult<Self>
pub fn empty_struct(rtti: Arc<Rtti>) -> VmResult<Self>
Construct an empty.
Sourcepub fn tuple_struct(rtti: Arc<Rtti>, vec: Vec<Value>) -> VmResult<Self>
pub fn tuple_struct(rtti: Arc<Rtti>, vec: Vec<Value>) -> VmResult<Self>
Construct a typed tuple.
Sourcepub fn unit_variant(rtti: Arc<VariantRtti>) -> VmResult<Self>
pub fn unit_variant(rtti: Arc<VariantRtti>) -> VmResult<Self>
Construct an empty variant.
Sourcepub fn tuple_variant(rtti: Arc<VariantRtti>, vec: Vec<Value>) -> VmResult<Self>
pub fn tuple_variant(rtti: Arc<VariantRtti>, vec: Vec<Value>) -> VmResult<Self>
Construct a tuple variant.
Sourcepub fn as_integer(&self) -> VmResult<i64>
pub fn as_integer(&self) -> VmResult<i64>
Try to coerce value into an integer.
Sourcepub fn into_integer(self) -> VmResult<i64>
pub fn into_integer(self) -> VmResult<i64>
Try to coerce value into an integer.
Sourcepub fn into_float(self) -> VmResult<f64>
pub fn into_float(self) -> VmResult<f64>
Try to coerce value into a float.
Sourcepub fn into_usize(self) -> VmResult<usize>
pub fn into_usize(self) -> VmResult<usize>
Try to coerce value into a usize.
Sourcepub fn as_ordering(&self) -> VmResult<Ordering>
pub fn as_ordering(&self) -> VmResult<Ordering>
Try to coerce value into an Ordering.
Sourcepub fn into_ordering(self) -> VmResult<Ordering>
pub fn into_ordering(self) -> VmResult<Ordering>
Try to coerce value into an Ordering.
Sourcepub fn into_result(self) -> VmResult<Shared<Result<Value, Value>>>
pub fn into_result(self) -> VmResult<Shared<Result<Value, Value>>>
Try to coerce value into a result.
Sourcepub fn as_result(&self) -> VmResult<&Shared<Result<Value, Value>>>
pub fn as_result(&self) -> VmResult<&Shared<Result<Value, Value>>>
Try to coerce value into a result.
Sourcepub fn into_generator(self) -> VmResult<Shared<Generator<Vm>>>
pub fn into_generator(self) -> VmResult<Shared<Generator<Vm>>>
Try to coerce value into a generator.
Sourcepub fn into_generator_state(self) -> VmResult<Shared<GeneratorState>>
pub fn into_generator_state(self) -> VmResult<Shared<GeneratorState>>
Try to coerce value into a future.
Sourcepub fn into_option(self) -> VmResult<Shared<Option<Value>>>
pub fn into_option(self) -> VmResult<Shared<Option<Value>>>
Try to coerce value into an option.
Sourcepub fn into_string(self) -> VmResult<Shared<String>>
pub fn into_string(self) -> VmResult<Shared<String>>
Try to coerce value into a string.
Sourcepub fn into_bytes(self) -> VmResult<Shared<Bytes>>
pub fn into_bytes(self) -> VmResult<Shared<Bytes>>
Try to coerce value into bytes.
Sourcepub fn into_tuple(self) -> VmResult<Shared<OwnedTuple>>
pub fn into_tuple(self) -> VmResult<Shared<OwnedTuple>>
Try to coerce value into a tuple.
Sourcepub fn into_object(self) -> VmResult<Shared<Object>>
pub fn into_object(self) -> VmResult<Shared<Object>>
Try to coerce value into an object.
Sourcepub fn into_range_from(self) -> VmResult<Shared<RangeFrom>>
pub fn into_range_from(self) -> VmResult<Shared<RangeFrom>>
Try to coerce value into a RangeFrom
.
Sourcepub fn into_range_full(self) -> VmResult<Shared<RangeFull>>
pub fn into_range_full(self) -> VmResult<Shared<RangeFull>>
Try to coerce value into a RangeFull
.
Sourcepub fn into_range_to_inclusive(self) -> VmResult<Shared<RangeToInclusive>>
pub fn into_range_to_inclusive(self) -> VmResult<Shared<RangeToInclusive>>
Try to coerce value into a RangeToInclusive
.
Sourcepub fn into_range_inclusive(self) -> VmResult<Shared<RangeInclusive>>
pub fn into_range_inclusive(self) -> VmResult<Shared<RangeInclusive>>
Try to coerce value into a RangeInclusive
.
Sourcepub fn into_control_flow(self) -> VmResult<Shared<ControlFlow>>
pub fn into_control_flow(self) -> VmResult<Shared<ControlFlow>>
Try to coerce value into a ControlFlow
.
Sourcepub fn into_function(self) -> VmResult<Shared<Function>>
pub fn into_function(self) -> VmResult<Shared<Function>>
Try to coerce value into a function pointer.
Sourcepub fn into_format(self) -> VmResult<Shared<Format>>
pub fn into_format(self) -> VmResult<Shared<Format>>
Try to coerce value into a format spec.
Sourcepub fn into_iterator(self) -> VmResult<Shared<Iterator>>
pub fn into_iterator(self) -> VmResult<Shared<Iterator>>
Try to coerce value into an iterator.
Sourcepub fn into_any_ptr<T>(self) -> VmResult<(NonNull<T>, RawRef)>where
T: Any,
pub fn into_any_ptr<T>(self) -> VmResult<(NonNull<T>, RawRef)>where
T: Any,
Try to coerce value into a ref and an associated guard.
§Safety
This coerces a strong guard to the value into its raw components.
It is up to the caller to ensure that the returned pointer does not outlive the returned guard, not the virtual machine the value belongs to.
Sourcepub fn into_any_mut<T>(self) -> VmResult<(NonNull<T>, RawMut)>where
T: Any,
pub fn into_any_mut<T>(self) -> VmResult<(NonNull<T>, RawMut)>where
T: Any,
Try to coerce value into a ref and an associated guard.
§Safety
This coerces a strong guard to the value into its raw components.
It is up to the caller to ensure that the returned pointer does not outlive the returned guard, not the virtual machine the value belongs to.
Sourcepub fn type_hash(&self) -> Result<Hash, VmError>
pub fn type_hash(&self) -> Result<Hash, VmError>
Get the type hash for the current value.
One notable feature is that the type of a variant is its container enum, and not the type hash of the variant itself.
Sourcepub fn partial_eq(a: &Value, b: &Value) -> VmResult<bool>
pub fn partial_eq(a: &Value, b: &Value) -> VmResult<bool>
Perform a partial equality test between two values.
This is the basis for the eq operation (partial_eq
/ ‘==’).
External types will use the Protocol::PARTIAL_EQ
protocol when
invoked through this function.
§Errors
This function will error if called outside of a virtual machine context.
Sourcepub fn eq(&self, b: &Value) -> VmResult<bool>
pub fn eq(&self, b: &Value) -> VmResult<bool>
Perform a total equality test between two values.
This is the basis for the eq operation (==
).
External types will use the Protocol::EQ
protocol when invoked
through this function.
§Errors
This function will error if called outside of a virtual machine context.
Sourcepub fn partial_cmp(a: &Value, b: &Value) -> VmResult<Option<Ordering>>
pub fn partial_cmp(a: &Value, b: &Value) -> VmResult<Option<Ordering>>
Perform a partial ordering comparison between two values.
This is the basis for the comparison operation.
External types will use the Protocol::PARTIAL_CMP
protocol when
invoked through this function.
§Errors
This function will error if called outside of a virtual machine context.
Sourcepub fn cmp(a: &Value, b: &Value) -> VmResult<Ordering>
pub fn cmp(a: &Value, b: &Value) -> VmResult<Ordering>
Perform a total ordering comparison between two values.
This is the basis for the comparison operation (cmp
).
External types will use the Protocol::CMP
protocol when invoked
through this function.
§Errors
This function will error if called outside of a virtual machine context.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
Deserialize implementation for value pointers.
impl<'de> Deserialize<'de> for Value
Deserialize implementation for value pointers.