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::sync::Arc;
use rune::{FromValue, Vm};
#[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 unit = Arc::try_new(unit)?;
let mut vm = Vm::without_runtime(unit)?;
let foo = vm.call(["main"], ())?;
let foo: Foo = rune::from_value(foo)?;
assert_eq!(foo.field, 42);Required Methods§
Sourcefn from_value(value: Value) -> Result<Self, RuntimeError>
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
impl FromValue for Ordering
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for bool
impl FromValue for bool
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for char
impl FromValue for char
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for f32
impl FromValue for f32
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for f64
impl FromValue for f64
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for i8
impl FromValue for i8
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for i16
impl FromValue for i16
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for i32
impl FromValue for i32
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for i64
impl FromValue for i64
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for i128
impl FromValue for i128
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for isize
impl FromValue for isize
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for u8
impl FromValue for u8
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for u16
impl FromValue for u16
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for u32
impl FromValue for u32
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for u64
impl FromValue for u64
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for u128
impl FromValue for u128
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for ()
impl FromValue for ()
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for usize
impl FromValue for usize
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for String
impl FromValue for String
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl FromValue for RangeFull
impl FromValue for RangeFull
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A> FromValue for (A,)where
A: FromValue,
impl<A> FromValue for (A,)where
A: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B> FromValue for (A, B)
impl<A, B> FromValue for (A, B)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C> FromValue for (A, B, C)
impl<A, B, C> FromValue for (A, B, C)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C, D> FromValue for (A, B, C, D)
impl<A, B, C, D> FromValue for (A, B, C, D)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C, D, E> FromValue for (A, B, C, D, E)
impl<A, B, C, D, E> FromValue for (A, B, C, D, E)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C, D, E, F> FromValue for (A, B, C, D, E, F)
impl<A, B, C, D, E, F> FromValue for (A, B, C, D, E, F)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C, D, E, F, G> FromValue for (A, B, C, D, E, F, G)
impl<A, B, C, D, E, F, G> FromValue for (A, B, C, D, E, F, G)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C, D, E, F, G, H> FromValue for (A, B, C, D, E, F, G, H)
impl<A, B, C, D, E, F, G, H> FromValue for (A, B, C, D, E, F, G, H)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C, D, E, F, G, H, I> FromValue for (A, B, C, D, E, F, G, H, I)
impl<A, B, C, D, E, F, G, H, I> FromValue for (A, B, C, D, E, F, G, H, I)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<A, B, C, D, E, F, G, H, I, J> FromValue for (A, B, C, D, E, F, G, H, I, J)
impl<A, B, C, D, E, F, G, H, I, J> FromValue for (A, B, C, D, E, F, G, H, I, J)
fn from_value(value: Value) -> Result<Self, RuntimeError>
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)
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)
fn from_value(value: Value) -> Result<Self, RuntimeError>
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)
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)
fn from_value(value: Value) -> Result<Self, RuntimeError>
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)
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)
fn from_value(value: Value) -> Result<Self, RuntimeError>
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)
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)
fn from_value(value: Value) -> Result<Self, RuntimeError>
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)
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)
fn from_value(value: Value) -> Result<Self, RuntimeError>
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)
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)
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<B, C> FromValue for ControlFlow<B, C>
impl<B, C> FromValue for ControlFlow<B, C>
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<Idx> FromValue for Range<Idx>where
Idx: FromValue,
impl<Idx> FromValue for Range<Idx>where
Idx: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<Idx> FromValue for RangeFrom<Idx>where
Idx: FromValue,
impl<Idx> FromValue for RangeFrom<Idx>where
Idx: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<Idx> FromValue for RangeInclusive<Idx>where
Idx: FromValue,
impl<Idx> FromValue for RangeInclusive<Idx>where
Idx: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<Idx> FromValue for RangeTo<Idx>where
Idx: FromValue,
impl<Idx> FromValue for RangeTo<Idx>where
Idx: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<Idx> FromValue for RangeToInclusive<Idx>where
Idx: FromValue,
impl<Idx> FromValue for RangeToInclusive<Idx>where
Idx: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<T> FromValue for Option<T>where
T: FromValue,
impl<T> FromValue for Option<T>where
T: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<T> FromValue for Vec<T>where
T: FromValue,
impl<T> FromValue for Vec<T>where
T: FromValue,
fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<T> FromValue for HashMap<String, T>where
T: FromValue,
Available on crate feature std only.
impl<T> FromValue for HashMap<String, T>where
T: FromValue,
Available on crate feature
std only.fn from_value(value: Value) -> Result<Self, RuntimeError>
Source§impl<T> FromValue for HashMap<String, T>where
T: FromValue,
Available on crate feature std only.
impl<T> FromValue for HashMap<String, T>where
T: FromValue,
Available on crate feature
std only.