rune

Trait ToValue

Source
pub trait ToValue: Sized {
    // Required method
    fn to_value(self) -> Result<Value, RuntimeError>;
}
Expand description

Trait for converting types into the dynamic Value container.

§Examples

use rune::{ToValue, Vm};
use std::sync::Arc;

#[derive(ToValue)]
struct Foo {
    field: u64,
}

let mut sources = rune::sources! {
    entry => {
        pub fn main(foo) {
            foo.field + 1
        }
    }
};

let unit = rune::prepare(&mut sources).build()?;

let mut vm = Vm::without_runtime(Arc::new(unit));
let foo = vm.call(["main"], (Foo { field: 42 },))?;
let foo: u64 = rune::from_value(foo)?;

assert_eq!(foo, 43);

Required Methods§

Source

fn to_value(self) -> Result<Value, RuntimeError>

Convert into a value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ToValue for &str

Source§

impl ToValue for Ordering

Source§

impl ToValue for bool

Source§

impl ToValue for char

Source§

impl ToValue for f32

Source§

impl ToValue for f64

Source§

impl ToValue for i8

Source§

impl ToValue for i16

Source§

impl ToValue for i32

Source§

impl ToValue for i64

Source§

impl ToValue for i128

Source§

impl ToValue for isize

Source§

impl ToValue for u8

Source§

impl ToValue for u16

Source§

impl ToValue for u32

Source§

impl ToValue for u64

Source§

impl ToValue for u128

Source§

impl ToValue for ()

Source§

impl ToValue for usize

Source§

impl ToValue for Box<str>

Source§

impl ToValue for String

Source§

impl ToValue for RangeFull

Source§

impl<A> ToValue for (A,)
where A: ToValue,

Source§

impl<A, B> ToValue for (A, B)
where A: ToValue, B: ToValue,

Source§

impl<A, B, C> ToValue for (A, B, C)
where A: ToValue, B: ToValue, C: ToValue,

Source§

impl<A, B, C, D> ToValue for (A, B, C, D)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue,

Source§

impl<A, B, C, D, E> ToValue for (A, B, C, D, E)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue,

Source§

impl<A, B, C, D, E, F> ToValue for (A, B, C, D, E, F)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue,

Source§

impl<A, B, C, D, E, F, G> ToValue for (A, B, C, D, E, F, G)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue,

Source§

impl<A, B, C, D, E, F, G, H> ToValue for (A, B, C, D, E, F, G, H)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I> ToValue for (A, B, C, D, E, F, G, H, I)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J> ToValue for (A, B, C, D, E, F, G, H, I, J)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K> ToValue for (A, B, C, D, E, F, G, H, I, J, K)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L> ToValue for (A, B, C, D, E, F, G, H, I, J, K, L)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M> ToValue for (A, B, C, D, E, F, G, H, I, J, K, L, M)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> ToValue for (A, B, C, D, E, F, G, H, I, J, K, L, M, N)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue, N: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> ToValue for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue, N: ToValue, O: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> ToValue for (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue, N: ToValue, O: ToValue, P: ToValue,

Source§

impl<B, C> ToValue for ControlFlow<B, C>
where B: ToValue, C: ToValue,

Source§

impl<Idx> ToValue for Range<Idx>
where Idx: ToValue,

Source§

impl<Idx> ToValue for RangeFrom<Idx>
where Idx: ToValue,

Source§

impl<Idx> ToValue for RangeInclusive<Idx>
where Idx: ToValue,

Source§

impl<Idx> ToValue for RangeTo<Idx>
where Idx: ToValue,

Source§

impl<Idx> ToValue for RangeToInclusive<Idx>
where Idx: ToValue,

Source§

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

Source§

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

Source§

impl<T> ToValue for HashMap<String, T>
where T: ToValue,

Source§

impl<T> ToValue for HashMap<String, T>
where T: ToValue,

Source§

impl<T, E> ToValue for Result<T, E>
where T: ToValue, E: ToValue,

Source§

impl<T, const N: usize> ToValue for [T; N]
where T: ToValue,

Implementors§

Source§

impl ToValue for &Value

Source§

impl ToValue for rune::alloc::Box<str>

Source§

impl ToValue for ConstValue

Source§

impl ToValue for Type

Source§

impl ToValue for Value

Source§

impl ToValue for VecTuple<()>

Source§

impl<A> ToValue for VecTuple<(A,)>
where A: ToValue,

Source§

impl<A, B> ToValue for VecTuple<(A, B)>
where A: ToValue, B: ToValue,

Source§

impl<A, B, C> ToValue for VecTuple<(A, B, C)>
where A: ToValue, B: ToValue, C: ToValue,

Source§

impl<A, B, C, D> ToValue for VecTuple<(A, B, C, D)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue,

Source§

impl<A, B, C, D, E> ToValue for VecTuple<(A, B, C, D, E)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue,

Source§

impl<A, B, C, D, E, F> ToValue for VecTuple<(A, B, C, D, E, F)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue,

Source§

impl<A, B, C, D, E, F, G> ToValue for VecTuple<(A, B, C, D, E, F, G)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue,

Source§

impl<A, B, C, D, E, F, G, H> ToValue for VecTuple<(A, B, C, D, E, F, G, H)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I, J)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I, J, K)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I, J, K, L)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I, J, K, L, M)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I, J, K, L, M, N)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue, N: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue, N: ToValue, O: ToValue,

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> ToValue for VecTuple<(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)>
where A: ToValue, B: ToValue, C: ToValue, D: ToValue, E: ToValue, F: ToValue, G: ToValue, H: ToValue, I: ToValue, J: ToValue, K: ToValue, L: ToValue, M: ToValue, N: ToValue, O: ToValue, P: ToValue,

Source§

impl<T> ToValue for rune::alloc::HashMap<String, T>
where T: ToValue,

Source§

impl<T> ToValue for rune::alloc::HashMap<String, T>
where T: ToValue,

Source§

impl<T> ToValue for rune::alloc::Vec<T>
where T: ToValue,

Source§

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