pub enum Value {
Show 28 variants
Unit,
Bool(bool),
Byte(u8),
Char(char),
Integer(i64),
Float(f64),
Type(Hash),
StaticString(Arc<StaticString>),
String(Shared<String>),
Bytes(Shared<Bytes>),
Vec(Shared<Vec>),
Tuple(Shared<Tuple>),
Object(Shared<Object>),
Range(Shared<Range>),
Future(Shared<Future>),
Stream(Shared<Stream<Vm>>),
Generator(Shared<Generator<Vm>>),
GeneratorState(Shared<GeneratorState>),
Option(Shared<Option<Value>>),
Result(Shared<Result<Value, Value>>),
UnitStruct(Shared<UnitStruct>),
TupleStruct(Shared<TupleStruct>),
Struct(Shared<Struct>),
Variant(Shared<Variant>),
Function(Shared<Function>),
Format(Box<Format>),
Iterator(Shared<Iterator>),
Any(Shared<AnyObj>),
}
Expand description
An entry on the stack.
Variants§
Unit
The unit value.
Bool(bool)
A boolean.
Byte(u8)
A single byte.
Char(char)
A character.
Integer(i64)
A number.
Float(f64)
A float.
Type(Hash)
A type hash. Describes a type in the virtual machine.
StaticString(Arc<StaticString>)
A static string.
While Rc<str>
would’ve been enough to store an unsized str
, either
Box<str>
or String
must be used to reduce the size of the type to
8 bytes, to ensure that a stack value is 16 bytes in size.
Rc<str>
on the other hand wraps a so-called fat pointer, which is 16
bytes.
String(Shared<String>)
A UTF-8 string.
Bytes(Shared<Bytes>)
A byte string.
Vec(Shared<Vec>)
A vector containing any values.
Tuple(Shared<Tuple>)
A tuple.
Object(Shared<Object>)
An object.
Range(Shared<Range>)
A range.
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.
UnitStruct(Shared<UnitStruct>)
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(Box<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,
s: &mut String,
buf: &mut String
) -> Result<Result, VmError>
pub fn string_display( &self, s: &mut String, buf: &mut String ) -> Result<Result, VmError>
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, s: &mut String) -> Result<Result, VmError>
pub fn string_debug(&self, s: &mut String) -> Result<Result, VmError>
Debug format the value using the Protocol::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) -> Result<Iterator, VmError>
pub fn into_iter(self) -> Result<Iterator, VmError>
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.
Panics
This function will panic if called outside of a virtual machine.
sourcepub fn into_future(self) -> Result<Future, VmError>
pub fn into_future(self) -> Result<Future, VmError>
Coerce into 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.
Panics
This function will panic if called outside of a virtual machine.
Coerce into a shared 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.
Panics
This function will panic if called outside of a virtual machine.
sourcepub fn into_type_name(self) -> Result<String, VmError>
pub fn into_type_name(self) -> Result<String, VmError>
sourcepub fn unit_struct(rtti: Arc<Rtti>) -> Self
pub fn unit_struct(rtti: Arc<Rtti>) -> Self
Construct an empty.
sourcepub fn unit_variant(rtti: Arc<VariantRtti>) -> Self
pub fn unit_variant(rtti: Arc<VariantRtti>) -> Self
Construct an empty variant.
sourcepub fn tuple_variant(rtti: Arc<VariantRtti>, vec: Vec<Value>) -> Self
pub fn tuple_variant(rtti: Arc<VariantRtti>, vec: Vec<Value>) -> Self
Construct a tuple variant.
sourcepub fn into_integer(self) -> Result<i64, VmError>
pub fn into_integer(self) -> Result<i64, VmError>
Try to coerce value into an integer.
sourcepub fn into_float(self) -> Result<f64, VmError>
pub fn into_float(self) -> Result<f64, VmError>
Try to coerce value into a float.
sourcepub fn into_result(self) -> Result<Shared<Result<Value, Value>>, VmError>
pub fn into_result(self) -> Result<Shared<Result<Value, Value>>, VmError>
Try to coerce value into a result.
sourcepub fn into_generator(self) -> Result<Shared<Generator<Vm>>, VmError>
pub fn into_generator(self) -> Result<Shared<Generator<Vm>>, VmError>
Try to coerce value into a generator.
sourcepub fn into_stream(self) -> Result<Shared<Stream<Vm>>, VmError>
pub fn into_stream(self) -> Result<Shared<Stream<Vm>>, VmError>
Try to coerce value into a stream.
sourcepub fn into_generator_state(self) -> Result<Shared<GeneratorState>, VmError>
pub fn into_generator_state(self) -> Result<Shared<GeneratorState>, VmError>
Try to coerce value into a future.
sourcepub fn into_option(self) -> Result<Shared<Option<Value>>, VmError>
pub fn into_option(self) -> Result<Shared<Option<Value>>, VmError>
Try to coerce value into an option.
sourcepub fn into_object(self) -> Result<Shared<Object>, VmError>
pub fn into_object(self) -> Result<Shared<Object>, VmError>
Try to coerce value into an object.
sourcepub fn into_function(self) -> Result<Shared<Function>, VmError>
pub fn into_function(self) -> Result<Shared<Function>, VmError>
Try to coerce value into a function pointer.
sourcepub fn into_format(self) -> Result<Box<Format>, VmError>
pub fn into_format(self) -> Result<Box<Format>, VmError>
Try to coerce value into a format spec.
sourcepub fn into_iterator(self) -> Result<Shared<Iterator>, VmError>
pub fn into_iterator(self) -> Result<Shared<Iterator>, VmError>
Try to coerce value into an iterator.
sourcepub fn into_any(self) -> Result<Shared<AnyObj>, VmError>
pub fn into_any(self) -> Result<Shared<AnyObj>, VmError>
Try to coerce value into an opaque value.
sourcepub fn into_any_ptr<T>(self) -> Result<(*const T, RawRef), VmError>where
T: Any,
pub fn into_any_ptr<T>(self) -> Result<(*const T, RawRef), VmError>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) -> Result<(*mut T, RawMut), VmError>where
T: Any,
pub fn into_any_mut<T>(self) -> Result<(*mut T, RawMut), VmError>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.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Deserialize implementation for value pointers.