Trait rune::runtime::ToValue

source ·
pub trait ToValue: Sized {
    // Required method
    fn to_value(self) -> VmResult<Value>;
}
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) -> VmResult<Value>

Convert into a value.

Object Safety§

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,

Implementors§

source§

impl ToValue for &Value

source§

impl ToValue for ConstValue

source§

impl ToValue for rune::runtime::ControlFlow

source§

impl ToValue for GeneratorState

source§

impl ToValue for Value

source§

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

source§

impl ToValue for rune::alloc::String

source§

impl ToValue for Format

source§

impl ToValue for AnyObj

source§

impl ToValue for Bytes

source§

impl ToValue for EmptyStruct

source§

impl ToValue for Function

source§

impl ToValue for Future

source§

impl ToValue for Generator<Vm>

source§

impl ToValue for Iterator

source§

impl ToValue for Object

source§

impl ToValue for OwnedTuple

source§

impl ToValue for rune::runtime::Range

source§

impl ToValue for rune::runtime::RangeFrom

source§

impl ToValue for rune::runtime::RangeFull

source§

impl ToValue for rune::runtime::RangeInclusive

source§

impl ToValue for rune::runtime::RangeTo

source§

impl ToValue for rune::runtime::RangeToInclusive

source§

impl ToValue for Shared<ControlFlow>

source§

impl ToValue for Shared<GeneratorState>

source§

impl ToValue for Shared<Option<Value>>

source§

impl ToValue for Shared<Result<Value, Value>>

source§

impl ToValue for Shared<String>

source§

impl ToValue for Shared<Format>

source§

impl ToValue for Shared<AnyObj>

source§

impl ToValue for Shared<Bytes>

source§

impl ToValue for Shared<EmptyStruct>

source§

impl ToValue for Shared<Function>

source§

impl ToValue for Shared<Future>

source§

impl ToValue for Shared<Generator<Vm>>

source§

impl ToValue for Shared<Iterator>

source§

impl ToValue for Shared<Object>

source§

impl ToValue for Shared<OwnedTuple>

source§

impl ToValue for Shared<Range>

source§

impl ToValue for Shared<RangeFrom>

source§

impl ToValue for Shared<RangeFull>

source§

impl ToValue for Shared<RangeInclusive>

source§

impl ToValue for Shared<RangeTo>

source§

impl ToValue for Shared<RangeToInclusive>

source§

impl ToValue for Shared<Stream<Vm>>

source§

impl ToValue for Shared<Struct>

source§

impl ToValue for Shared<TupleStruct>

source§

impl ToValue for Shared<Variant>

source§

impl ToValue for Shared<Vec>

source§

impl ToValue for Stream<Vm>

source§

impl ToValue for Struct

source§

impl ToValue for TupleStruct

source§

impl ToValue for Type

source§

impl ToValue for Variant

source§

impl ToValue for rune::runtime::Vec

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 VmResult<T>
where T: 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: Any,