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
sourceimpl 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
sourceimpl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Deserialize implementation for value pointers.
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<Arc<StaticString>> for Value
impl From<Arc<StaticString>> for Value
sourcefn from(value: Arc<StaticString>) -> Self
fn from(value: Arc<StaticString>) -> Self
Converts to this type from the input type.
sourceimpl From<GeneratorState> for Value
impl From<GeneratorState> for Value
sourcefn from(value: GeneratorState) -> Self
fn from(value: GeneratorState) -> Self
Converts to this type from the input type.
sourcefn from(value: Shared<GeneratorState>) -> Self
fn from(value: Shared<GeneratorState>) -> Self
Converts to this type from the input type.
sourcefn from(value: Shared<TupleStruct>) -> Self
fn from(value: Shared<TupleStruct>) -> Self
Converts to this type from the input type.
sourcefn from(value: Shared<UnitStruct>) -> Self
fn from(value: Shared<UnitStruct>) -> Self
Converts to this type from the input type.
sourceimpl From<StaticString> for Value
impl From<StaticString> for Value
sourcefn from(value: StaticString) -> Self
fn from(value: StaticString) -> Self
Converts to this type from the input type.
sourceimpl From<TupleStruct> for Value
impl From<TupleStruct> for Value
sourcefn from(value: TupleStruct) -> Self
fn from(value: TupleStruct) -> Self
Converts to this type from the input type.
sourceimpl From<UnitStruct> for Value
impl From<UnitStruct> for Value
sourcefn from(value: UnitStruct) -> Self
fn from(value: UnitStruct) -> Self
Converts to this type from the input type.
sourceimpl FromIterator<Value> for Stack
impl FromIterator<Value> for Stack
sourcefn from_iter<T: IntoIterator<Item = Value>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Value>>(iter: T) -> Self
Creates a value from an iterator. Read more
sourceimpl FromValue for Value
impl FromValue for Value
sourcefn from_value(value: Value) -> Result<Self, VmError>
fn from_value(value: Value) -> Result<Self, VmError>
Try to convert to the given type, from the given value.
Auto Trait Implementations
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl Unpin for Value
impl !UnwindSafe for Value
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more