Struct rune::Value

source ·
pub struct Value { /* private fields */ }
Expand description

An entry on the stack.

Implementations§

source§

impl Value

source

pub unsafe fn from_ref<T>(data: &T) -> Result<(Self, SharedPointerGuard)>
where T: Any,

Construct an Any that wraps a pointer.

§Safety

Caller must ensure that the returned Value doesn’t outlive the reference it is wrapping.

This would be an example of incorrect use:

use rune::Any;
use rune::runtime::Value;

#[derive(Any)]
struct Foo(u32);

let mut v = Foo(1u32);

unsafe {
    let (any, guard) = unsafe { Value::from_ref(&v)? };
    drop(v);
    // any use of `any` beyond here is undefined behavior.
}
§Examples
use rune::Any;
use rune::runtime::Value;

#[derive(Any)]
struct Foo(u32);

let mut v = Foo(1u32);

unsafe {
    let (any, guard) = Value::from_ref(&mut v)?;
    let b = any.into_any_ref::<Foo>().unwrap();
    assert_eq!(b.0, 1u32);
}
source

pub unsafe fn from_mut<T>(data: &mut T) -> Result<(Self, SharedPointerGuard)>
where T: Any,

Construct a value that wraps a mutable pointer.

§Safety

Caller must ensure that the returned Value doesn’t outlive the reference it is wrapping.

This would be an example of incorrect use:

use rune::Any;
use rune::runtime::Value;

#[derive(Any)]
struct Foo(u32);

let mut v = Foo(1u32);
unsafe {
    let (any, guard) = Value::from_mut(&mut v)?;
    drop(v);
    // any use of value beyond here is undefined behavior.
}
§Examples
use rune::Any;
use rune::runtime::{Value, VmResult};

#[derive(Any)]
struct Foo(u32);

let mut v = Foo(1u32);

unsafe {
    let (mut any, guard) = Value::from_mut(&mut v)?;

    if let Ok(mut v) = any.into_any_mut::<Foo>() {
        v.0 += 1;
    }
}

assert_eq!(v.0, 2);
source

pub fn is_writable(&self) -> bool

Test if the value is writable.

source

pub fn is_readable(&self) -> bool

Test if the value is readable.

source

pub fn snapshot(&self) -> Snapshot

Get snapshot of value.

The snapshot details how the value is currently being access.

source

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.

source

pub fn clone_(&self) -> VmResult<Self>

Perform a shallow clone of the value using the CLONE protocol.

This requires read access to the underlying value.

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.

source

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.

source

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.

source

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.

source

pub fn vec(vec: Vec<Value>) -> VmResult<Self>

Construct a vector.

source

pub fn tuple(vec: Vec<Value>) -> VmResult<Self>

Construct a tuple.

source

pub fn empty_struct(rtti: Arc<Rtti>) -> VmResult<Self>

Construct an empty.

source

pub fn tuple_struct(rtti: Arc<Rtti>, vec: Vec<Value>) -> VmResult<Self>

Construct a typed tuple.

source

pub fn unit_variant(rtti: Arc<VariantRtti>) -> VmResult<Self>

Construct an empty variant.

source

pub fn tuple_variant(rtti: Arc<VariantRtti>, vec: Vec<Value>) -> VmResult<Self>

Construct a tuple variant.

source

pub fn as_usize(&self) -> Result<usize, RuntimeError>

Try to coerce value into a usize.

source

pub fn as_string(&self) -> Result<BorrowRef<'_, str>, RuntimeError>

👎Deprecated: For consistency with other methods, this has been renamed Value::borrow_string_ref

Get the value as a string.

source

pub fn borrow_string_ref(&self) -> Result<BorrowRef<'_, str>, RuntimeError>

Borrow the value of a string as a reference.

source

pub fn into_string(self) -> Result<String, RuntimeError>

Take the current value as a string.

source

pub fn into_unit(&self) -> Result<(), RuntimeError>

Coerce into a unit.

source

pub fn into_ordering_ref(self) -> Result<Ref<Ordering>, RuntimeError>

Coerce into Ordering.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_ordering_mut(self) -> Result<Mut<Ordering>, RuntimeError>

Coerce into Ordering.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_ordering_ref( &self ) -> Result<BorrowRef<'_, Ordering>, RuntimeError>

Coerce into Ordering.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_ordering_mut( &self ) -> Result<BorrowMut<'_, Ordering>, RuntimeError>

Coerce into Ordering.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_ordering(&self) -> Result<Ordering, RuntimeError>

Coerce into Ordering.

This copied the underlying value.

source

pub fn into_bool_ref(self) -> Result<Ref<bool>, RuntimeError>

Coerce into bool.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_bool_mut(self) -> Result<Mut<bool>, RuntimeError>

Coerce into bool.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_bool_ref(&self) -> Result<BorrowRef<'_, bool>, RuntimeError>

Coerce into bool.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_bool_mut(&self) -> Result<BorrowMut<'_, bool>, RuntimeError>

Coerce into bool.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_bool(&self) -> Result<bool, RuntimeError>

Coerce into bool.

This copied the underlying value.

source

pub fn into_byte_ref(self) -> Result<Ref<u8>, RuntimeError>

Coerce into u8 byte.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_byte_mut(self) -> Result<Mut<u8>, RuntimeError>

Coerce into u8 byte.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_byte_ref(&self) -> Result<BorrowRef<'_, u8>, RuntimeError>

Coerce into u8 byte.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_byte_mut(&self) -> Result<BorrowMut<'_, u8>, RuntimeError>

Coerce into u8 byte.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_byte(&self) -> Result<u8, RuntimeError>

Coerce into u8 byte.

This copied the underlying value.

source

pub fn into_char_ref(self) -> Result<Ref<char>, RuntimeError>

Coerce into char.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_char_mut(self) -> Result<Mut<char>, RuntimeError>

Coerce into char.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_char_ref(&self) -> Result<BorrowRef<'_, char>, RuntimeError>

Coerce into char.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_char_mut(&self) -> Result<BorrowMut<'_, char>, RuntimeError>

Coerce into char.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_char(&self) -> Result<char, RuntimeError>

Coerce into char.

This copied the underlying value.

source

pub fn into_integer_ref(self) -> Result<Ref<i64>, RuntimeError>

Coerce into i64 integer.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_integer_mut(self) -> Result<Mut<i64>, RuntimeError>

Coerce into i64 integer.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_integer_ref(&self) -> Result<BorrowRef<'_, i64>, RuntimeError>

Coerce into i64 integer.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_integer_mut(&self) -> Result<BorrowMut<'_, i64>, RuntimeError>

Coerce into i64 integer.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_integer(&self) -> Result<i64, RuntimeError>

Coerce into i64 integer.

This copied the underlying value.

source

pub fn into_float_ref(self) -> Result<Ref<f64>, RuntimeError>

Coerce into f64 float.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_float_mut(self) -> Result<Mut<f64>, RuntimeError>

Coerce into f64 float.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_float_ref(&self) -> Result<BorrowRef<'_, f64>, RuntimeError>

Coerce into f64 float.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_float_mut(&self) -> Result<BorrowMut<'_, f64>, RuntimeError>

Coerce into f64 float.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_float(&self) -> Result<f64, RuntimeError>

Coerce into f64 float.

This copied the underlying value.

source

pub fn into_type_ref(self) -> Result<Ref<Type>, RuntimeError>

Coerce into Type.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_type_mut(self) -> Result<Mut<Type>, RuntimeError>

Coerce into Type.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_type_ref(&self) -> Result<BorrowRef<'_, Type>, RuntimeError>

Coerce into Type.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_type_mut(&self) -> Result<BorrowMut<'_, Type>, RuntimeError>

Coerce into Type.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_type(&self) -> Result<Type, RuntimeError>

Coerce into Type.

This copied the underlying value.

source

pub fn into_option_ref(self) -> Result<Ref<Option<Value>>, RuntimeError>

Coerce into Option.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_option_mut(self) -> Result<Mut<Option<Value>>, RuntimeError>

Coerce into Option.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_option_ref( &self ) -> Result<BorrowRef<'_, Option<Value>>, RuntimeError>

Coerce into Option.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_option_mut( &self ) -> Result<BorrowMut<'_, Option<Value>>, RuntimeError>

Coerce into Option.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_option(&self) -> Result<Option<Value>, RuntimeError>

Coerce into Option.

This clones the underlying value.

source

pub fn into_result_ref(self) -> Result<Ref<Result<Value, Value>>, RuntimeError>

Coerce into Result.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_result_mut(self) -> Result<Mut<Result<Value, Value>>, RuntimeError>

Coerce into Result.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_result_ref( &self ) -> Result<BorrowRef<'_, Result<Value, Value>>, RuntimeError>

Coerce into Result.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_result_mut( &self ) -> Result<BorrowMut<'_, Result<Value, Value>>, RuntimeError>

Coerce into Result.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn as_result(&self) -> Result<Result<Value, Value>, RuntimeError>

Coerce into Result.

This clones the underlying value.

source

pub fn into_vec_ref(self) -> Result<Ref<Vec>, RuntimeError>

Coerce into Vec.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_vec_mut(self) -> Result<Mut<Vec>, RuntimeError>

Coerce into Vec.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_vec_ref(&self) -> Result<BorrowRef<'_, Vec>, RuntimeError>

Coerce into Vec.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_vec_mut(&self) -> Result<BorrowMut<'_, Vec>, RuntimeError>

Coerce into Vec.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_vec(self) -> Result<Vec, RuntimeError>

Coerce into Vec.

This consumes the underlying value.

source

pub fn into_bytes_ref(self) -> Result<Ref<Bytes>, RuntimeError>

Coerce into Bytes.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_bytes_mut(self) -> Result<Mut<Bytes>, RuntimeError>

Coerce into Bytes.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_bytes_ref(&self) -> Result<BorrowRef<'_, Bytes>, RuntimeError>

Coerce into Bytes.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_bytes_mut(&self) -> Result<BorrowMut<'_, Bytes>, RuntimeError>

Coerce into Bytes.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_bytes(self) -> Result<Bytes, RuntimeError>

Coerce into Bytes.

This consumes the underlying value.

source

pub fn into_control_flow_ref(self) -> Result<Ref<ControlFlow>, RuntimeError>

Coerce into a ControlFlow.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_control_flow_mut(self) -> Result<Mut<ControlFlow>, RuntimeError>

Coerce into a ControlFlow.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_control_flow_ref( &self ) -> Result<BorrowRef<'_, ControlFlow>, RuntimeError>

Coerce into a ControlFlow.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_control_flow_mut( &self ) -> Result<BorrowMut<'_, ControlFlow>, RuntimeError>

Coerce into a ControlFlow.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_control_flow(self) -> Result<ControlFlow, RuntimeError>

Coerce into a ControlFlow.

This consumes the underlying value.

source

pub fn into_function_ref(self) -> Result<Ref<Function>, RuntimeError>

Coerce into a Function.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_function_mut(self) -> Result<Mut<Function>, RuntimeError>

Coerce into a Function.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_function_ref( &self ) -> Result<BorrowRef<'_, Function>, RuntimeError>

Coerce into a Function.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_function_mut( &self ) -> Result<BorrowMut<'_, Function>, RuntimeError>

Coerce into a Function.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_function(self) -> Result<Function, RuntimeError>

Coerce into a Function.

This consumes the underlying value.

source

pub fn into_generator_state_ref( self ) -> Result<Ref<GeneratorState>, RuntimeError>

Coerce into a GeneratorState.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_generator_state_mut( self ) -> Result<Mut<GeneratorState>, RuntimeError>

Coerce into a GeneratorState.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_generator_state_ref( &self ) -> Result<BorrowRef<'_, GeneratorState>, RuntimeError>

Coerce into a GeneratorState.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_generator_state_mut( &self ) -> Result<BorrowMut<'_, GeneratorState>, RuntimeError>

Coerce into a GeneratorState.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_generator_state(self) -> Result<GeneratorState, RuntimeError>

Coerce into a GeneratorState.

This consumes the underlying value.

source

pub fn into_generator_ref(self) -> Result<Ref<Generator<Vm>>, RuntimeError>

Coerce into a Generator.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_generator_mut(self) -> Result<Mut<Generator<Vm>>, RuntimeError>

Coerce into a Generator.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_generator_ref( &self ) -> Result<BorrowRef<'_, Generator<Vm>>, RuntimeError>

Coerce into a Generator.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_generator_mut( &self ) -> Result<BorrowMut<'_, Generator<Vm>>, RuntimeError>

Coerce into a Generator.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_generator(self) -> Result<Generator<Vm>, RuntimeError>

Coerce into a Generator.

This consumes the underlying value.

source

pub fn into_iterator_ref(self) -> Result<Ref<Iterator>, RuntimeError>

Coerce into a Iterator.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_iterator_mut(self) -> Result<Mut<Iterator>, RuntimeError>

Coerce into a Iterator.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_iterator_ref( &self ) -> Result<BorrowRef<'_, Iterator>, RuntimeError>

Coerce into a Iterator.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_iterator_mut( &self ) -> Result<BorrowMut<'_, Iterator>, RuntimeError>

Coerce into a Iterator.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_iterator(self) -> Result<Iterator, RuntimeError>

Coerce into a Iterator.

This consumes the underlying value.

source

pub fn into_format_ref(self) -> Result<Ref<Format>, RuntimeError>

Coerce into a Format.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_format_mut(self) -> Result<Mut<Format>, RuntimeError>

Coerce into a Format.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_format_ref(&self) -> Result<BorrowRef<'_, Format>, RuntimeError>

Coerce into a Format.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_format_mut(&self) -> Result<BorrowMut<'_, Format>, RuntimeError>

Coerce into a Format.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_format(self) -> Result<Format, RuntimeError>

Coerce into a Format.

This consumes the underlying value.

source

pub fn into_tuple_ref(self) -> Result<Ref<OwnedTuple>, RuntimeError>

Coerce into Tuple.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_tuple_mut(self) -> Result<Mut<OwnedTuple>, RuntimeError>

Coerce into Tuple.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_tuple_ref( &self ) -> Result<BorrowRef<'_, OwnedTuple>, RuntimeError>

Coerce into Tuple.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_tuple_mut( &self ) -> Result<BorrowMut<'_, OwnedTuple>, RuntimeError>

Coerce into Tuple.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_tuple(self) -> Result<OwnedTuple, RuntimeError>

Coerce into Tuple.

This consumes the underlying value.

source

pub fn into_struct_ref(self) -> Result<Ref<Struct>, RuntimeError>

Coerce into Struct

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_struct_mut(self) -> Result<Mut<Struct>, RuntimeError>

Coerce into Struct

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_struct_ref(&self) -> Result<BorrowRef<'_, Struct>, RuntimeError>

Coerce into Struct

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_struct_mut(&self) -> Result<BorrowMut<'_, Struct>, RuntimeError>

Coerce into Struct

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_struct(self) -> Result<Struct, RuntimeError>

Coerce into Struct

This consumes the underlying value.

source

pub fn into_object_ref(self) -> Result<Ref<Object>, RuntimeError>

Coerce into a Object.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_object_mut(self) -> Result<Mut<Object>, RuntimeError>

Coerce into a Object.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_object_ref(&self) -> Result<BorrowRef<'_, Object>, RuntimeError>

Coerce into a Object.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_object_mut(&self) -> Result<BorrowMut<'_, Object>, RuntimeError>

Coerce into a Object.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_object(self) -> Result<Object, RuntimeError>

Coerce into a Object.

This consumes the underlying value.

source

pub fn into_range_from_ref(self) -> Result<Ref<RangeFrom>, RuntimeError>

Coerce into a RangeFrom.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_range_from_mut(self) -> Result<Mut<RangeFrom>, RuntimeError>

Coerce into a RangeFrom.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_range_from_ref( &self ) -> Result<BorrowRef<'_, RangeFrom>, RuntimeError>

Coerce into a RangeFrom.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_range_from_mut( &self ) -> Result<BorrowMut<'_, RangeFrom>, RuntimeError>

Coerce into a RangeFrom.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_range_from(self) -> Result<RangeFrom, RuntimeError>

Coerce into a RangeFrom.

This consumes the underlying value.

source

pub fn into_range_full_ref(self) -> Result<Ref<RangeFull>, RuntimeError>

Coerce into a RangeFull.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_range_full_mut(self) -> Result<Mut<RangeFull>, RuntimeError>

Coerce into a RangeFull.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_range_full_ref( &self ) -> Result<BorrowRef<'_, RangeFull>, RuntimeError>

Coerce into a RangeFull.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_range_full_mut( &self ) -> Result<BorrowMut<'_, RangeFull>, RuntimeError>

Coerce into a RangeFull.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_range_full(self) -> Result<RangeFull, RuntimeError>

Coerce into a RangeFull.

This consumes the underlying value.

source

pub fn into_range_to_inclusive_ref( self ) -> Result<Ref<RangeToInclusive>, RuntimeError>

Coerce into a RangeToInclusive.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_range_to_inclusive_mut( self ) -> Result<Mut<RangeToInclusive>, RuntimeError>

Coerce into a RangeToInclusive.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_range_to_inclusive_ref( &self ) -> Result<BorrowRef<'_, RangeToInclusive>, RuntimeError>

Coerce into a RangeToInclusive.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_range_to_inclusive_mut( &self ) -> Result<BorrowMut<'_, RangeToInclusive>, RuntimeError>

Coerce into a RangeToInclusive.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_range_to_inclusive(self) -> Result<RangeToInclusive, RuntimeError>

Coerce into a RangeToInclusive.

This consumes the underlying value.

source

pub fn into_range_inclusive_ref( self ) -> Result<Ref<RangeInclusive>, RuntimeError>

Coerce into a RangeInclusive.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_range_inclusive_mut( self ) -> Result<Mut<RangeInclusive>, RuntimeError>

Coerce into a RangeInclusive.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_range_inclusive_ref( &self ) -> Result<BorrowRef<'_, RangeInclusive>, RuntimeError>

Coerce into a RangeInclusive.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_range_inclusive_mut( &self ) -> Result<BorrowMut<'_, RangeInclusive>, RuntimeError>

Coerce into a RangeInclusive.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_range_inclusive(self) -> Result<RangeInclusive, RuntimeError>

Coerce into a RangeInclusive.

This consumes the underlying value.

source

pub fn into_range_to_ref(self) -> Result<Ref<RangeTo>, RuntimeError>

Coerce into a RangeTo.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_range_to_mut(self) -> Result<Mut<RangeTo>, RuntimeError>

Coerce into a RangeTo.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_range_to_ref( &self ) -> Result<BorrowRef<'_, RangeTo>, RuntimeError>

Coerce into a RangeTo.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_range_to_mut( &self ) -> Result<BorrowMut<'_, RangeTo>, RuntimeError>

Coerce into a RangeTo.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_range_to(self) -> Result<RangeTo, RuntimeError>

Coerce into a RangeTo.

This consumes the underlying value.

source

pub fn into_range_ref(self) -> Result<Ref<Range>, RuntimeError>

Coerce into a Range.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_range_mut(self) -> Result<Mut<Range>, RuntimeError>

Coerce into a Range.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_range_ref(&self) -> Result<BorrowRef<'_, Range>, RuntimeError>

Coerce into a Range.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_range_mut(&self) -> Result<BorrowMut<'_, Range>, RuntimeError>

Coerce into a Range.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_range(self) -> Result<Range, RuntimeError>

Coerce into a Range.

This consumes the underlying value.

source

pub fn into_stream_ref(self) -> Result<Ref<Stream<Vm>>, RuntimeError>

Coerce into a Stream.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_stream_mut(self) -> Result<Mut<Stream<Vm>>, RuntimeError>

Coerce into a Stream.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_stream_ref( &self ) -> Result<BorrowRef<'_, Stream<Vm>>, RuntimeError>

Coerce into a Stream.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_stream_mut( &self ) -> Result<BorrowMut<'_, Stream<Vm>>, RuntimeError>

Coerce into a Stream.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_stream(self) -> Result<Stream<Vm>, RuntimeError>

Coerce into a Stream.

This consumes the underlying value.

source

pub fn into_future_ref(self) -> Result<Ref<Future>, RuntimeError>

Coerce into a Future.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn into_future_mut(self) -> Result<Mut<Future>, RuntimeError>

Coerce into a Future.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn borrow_future_ref(&self) -> Result<BorrowRef<'_, Future>, RuntimeError>

Coerce into a Future.

This ensures that the value has read access to the underlying value and does not consume it.

source

pub fn borrow_future_mut(&self) -> Result<BorrowMut<'_, Future>, RuntimeError>

Coerce into a Future.

This ensures that the value has write access to the underlying value and does not consume it.

source

pub fn into_any_obj(self) -> Result<AnyObj, RuntimeError>

Coerce into an AnyObj.

This consumes the underlying value.

source

pub fn into_future(self) -> VmResult<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.

source

pub fn into_any_ref<T>(self) -> Result<Ref<T>, RuntimeError>
where T: Any,

Try to coerce value into a typed reference.

source

pub fn into_any_mut<T>(self) -> Result<Mut<T>, RuntimeError>
where T: Any,

Try to coerce value into a typed mutable reference.

source

pub fn borrow_any_ref<T>(&self) -> Result<BorrowRef<'_, T>, RuntimeError>
where T: Any,

Borrow the value as a typed reference.

source

pub fn borrow_any_mut<T>(&self) -> Result<BorrowMut<'_, T>, RuntimeError>
where T: Any,

Borrow the value as a mutable typed reference.

source

pub fn into_any<T>(self) -> Result<T, RuntimeError>
where T: Any,

Try to coerce value into a typed value.

source

pub fn type_hash(&self) -> Result<Hash, AccessError>

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.

source

pub fn type_info(&self) -> Result<TypeInfo, AccessError>

Get the type information for the current value.

source

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.

source

pub fn hash(&self, hasher: &mut Hasher) -> VmResult<()>

Hash the current value.

source

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.

source

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.

source

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.

source

pub fn try_as_integer<T>(&self) -> Result<T, RuntimeError>

Try to coerce the current value as the specified integer T.

§Examples
use rune::runtime::{Value, VmResult};

let value = rune::to_value(u32::MAX)?;

assert_eq!(value.try_as_integer::<u64>(), Ok(u32::MAX as u64));
assert!(value.try_as_integer::<i32>().is_err());

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

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 Value

source§

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

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

impl<'de> Deserialize<'de> for Value

Deserialize implementation for value pointers.

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FromValue for Value

source§

fn from_value(value: Value) -> VmResult<Self>

Try to convert to the given type, from the given value.
source§

impl MaybeTypeOf for Value

source§

fn maybe_type_of() -> Option<FullTypeOf>

Type information for the given type.
source§

impl Serialize for Value

Serialize implementation for value pointers.

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ToValue for &Value

source§

fn to_value(self) -> VmResult<Value>

Convert into a value.
source§

impl ToValue for Value

source§

fn to_value(self) -> VmResult<Value>

Convert into a value.
source§

impl TryClone for Value

source§

fn try_clone(&self) -> Result<Self>

Try to clone the current value, raising an allocation error if it’s unsuccessful.
source§

fn try_clone_from(&mut self, source: &Self) -> Result<(), Error>

Performs copy-assignment from source. Read more
source§

impl TryFrom<()> for Value

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<AnyObj> for Value

§

type Error = Error

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

fn try_from(value: AnyObj) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Bytes> for Value

§

type Error = Error

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

fn try_from(value: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<ControlFlow> for Value

§

type Error = Error

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

fn try_from(value: ControlFlow) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<EmptyStruct> for Value

§

type Error = Error

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

fn try_from(value: EmptyStruct) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Format> for Value

§

type Error = Error

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

fn try_from(value: Format) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Function> for Value

§

type Error = Error

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

fn try_from(value: Function) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Future> for Value

§

type Error = Error

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

fn try_from(value: Future) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Generator<Vm>> for Value

§

type Error = Error

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

fn try_from(value: Generator<Vm>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<GeneratorState> for Value

§

type Error = Error

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

fn try_from(value: GeneratorState) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Iterator> for Value

§

type Error = Error

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

fn try_from(value: Iterator) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Object> for Value

§

type Error = Error

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

fn try_from(value: Object) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Option<Value>> for Value

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Ordering> for Value

§

type Error = Error

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

fn try_from(value: Ordering) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<OwnedTuple> for Value

§

type Error = Error

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

fn try_from(value: OwnedTuple) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Range> for Value

§

type Error = Error

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

fn try_from(value: Range) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<RangeFrom> for Value

§

type Error = Error

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

fn try_from(value: RangeFrom) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<RangeFull> for Value

§

type Error = Error

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

fn try_from(value: RangeFull) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<RangeInclusive> for Value

§

type Error = Error

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

fn try_from(value: RangeInclusive) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<RangeTo> for Value

§

type Error = Error

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

fn try_from(value: RangeTo) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<RangeToInclusive> for Value

§

type Error = Error

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

fn try_from(value: RangeToInclusive) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Result<Value, Value>> for Value

§

type Error = Error

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

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

Performs the conversion.
source§

impl TryFrom<Stream<Vm>> for Value

§

type Error = Error

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

fn try_from(value: Stream<Vm>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<String> for Value

§

type Error = Error

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

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Struct> for Value

§

type Error = Error

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

fn try_from(value: Struct) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<TupleStruct> for Value

§

type Error = Error

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

fn try_from(value: TupleStruct) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Type> for Value

§

type Error = Error

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

fn try_from(value: Type) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Variant> for Value

§

type Error = Error

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

fn try_from(value: Variant) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Vec> for Value

§

type Error = Error

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

fn try_from(value: Vec) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<bool> for Value

§

type Error = Error

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

fn try_from(value: bool) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<char> for Value

§

type Error = Error

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

fn try_from(value: char) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<f64> for Value

§

type Error = Error

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

fn try_from(value: f64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<i64> for Value

§

type Error = Error

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

fn try_from(value: i64) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<u8> for Value

§

type Error = Error

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

fn try_from(value: u8) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFromIteratorIn<Value, Global> for Stack

source§

fn try_from_iter_in<T: IntoIterator<Item = Value>>( iter: T, alloc: Global ) -> Result<Self>

Creates a value from an iterator within an allocator.

Auto Trait Implementations§

§

impl Freeze for Value

§

impl !RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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<T> TryToOwned for T
where T: TryClone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn try_to_owned(&self) -> Result<T, Error>

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

impl<T> UnsafeToValue for T
where T: ToValue,

§

type Guard = ()

The type used to guard the unsafe value conversion.
source§

unsafe fn unsafe_to_value( self ) -> VmResult<(Value, <T as UnsafeToValue>::Guard)>

Convert into a value. Read more
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,