rune::runtime

Trait FromValue

Source
pub trait FromValue: 'static + Sized {
    // Required method
    fn from_value(value: Value) -> Result<Self, RuntimeError>;
}
Expand description

Trait for converting types from the dynamic Value container.

§Examples

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

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

let mut sources = rune::sources!(entry => {
    pub fn main() { #{field: 42} }
});

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

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

assert_eq!(foo.field, 42);

Required Methods§

Source

fn from_value(value: Value) -> Result<Self, RuntimeError>

Try to convert to the given type, from the given 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 FromValue for Ordering

Source§

impl FromValue for bool

Source§

impl FromValue for char

Source§

impl FromValue for f32

Source§

impl FromValue for f64

Source§

impl FromValue for i8

Source§

impl FromValue for i16

Source§

impl FromValue for i32

Source§

impl FromValue for i64

Source§

impl FromValue for i128

Source§

impl FromValue for isize

Source§

impl FromValue for u8

Source§

impl FromValue for u16

Source§

impl FromValue for u32

Source§

impl FromValue for u64

Source§

impl FromValue for u128

Source§

impl FromValue for ()

Source§

impl FromValue for usize

Source§

impl FromValue for Box<str>

Source§

impl FromValue for String

Source§

impl FromValue for RangeFull

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<A, B, C, D, E, F> FromValue for (A, B, C, D, E, F)

Source§

impl<A, B, C, D, E, F, G> FromValue for (A, B, C, D, E, F, G)

Source§

impl<A, B, C, D, E, F, G, H> FromValue for (A, B, C, D, E, F, G, H)

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§

Source§

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

Source§

impl FromValue for rune::alloc::Box<Tuple>

Source§

impl FromValue for AnyObj

Source§

impl FromValue for ConstValue

Source§

impl FromValue for DynamicEmpty

Source§

impl FromValue for DynamicStruct

Source§

impl FromValue for DynamicTuple

Source§

impl FromValue for Iterator

Source§

impl FromValue for Mut<Tuple>

Source§

impl FromValue for Ref<str>

Source§

impl FromValue for Ref<Tuple>

Source§

impl FromValue for SyncFunction

Source§

impl FromValue for Type

Source§

impl FromValue for Value

Source§

impl FromValue for VecTuple<()>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<A, B, C, D, E, F> FromValue for VecTuple<(A, B, C, D, E, F)>

Source§

impl<A, B, C, D, E, F, G> FromValue for VecTuple<(A, B, C, D, E, F, G)>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T> FromValue for Mut<T>
where T: AnyMarker,

Source§

impl<T> FromValue for Ref<T>
where T: AnyMarker,

Source§

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