#[non_exhaustive]pub struct Output { /* private fields */ }
Expand description
What to do with the output of an instruction.
Implementations§
Source§impl Output
impl Output
Sourcepub fn store<M, O>(self, stack: &mut M, o: O) -> Result<(), RuntimeError>
pub fn store<M, O>(self, stack: &mut M, o: O) -> Result<(), RuntimeError>
Write output using the provided IntoOutput
implementation onto the
stack.
The IntoOutput
trait primarily allows for deferring a computation
since it’s implemented by FnOnce
. However, you must take care that
any side effects calling a function may have are executed outside of the
call to store
. Like if the function would error.
§Examples
use rune::runtime::{Output, Memory, ToValue, VmResult, InstAddress};
use rune::vm_try;
fn sum(stack: &mut dyn Memory, addr: InstAddress, args: usize, out: Output) -> VmResult<()> {
let mut number = 0;
for value in vm_try!(stack.slice_at(addr, args)) {
number += vm_try!(value.as_integer::<i64>());
}
out.store(stack, number);
VmResult::Ok(())
}
Trait Implementations§
Source§impl<'__de, __A> Decode<'__de, Binary, __A> for Outputwhere
__A: Allocator,
impl<'__de, __A> Decode<'__de, Binary, __A> for Outputwhere
__A: Allocator,
Source§const IS_BITWISE_DECODE: bool = false
const IS_BITWISE_DECODE: bool = false
Whether the type is packed. Packed types can be bitwise copied if the
representation of the serialization format is identical to the memory
layout of the type. Read more
Source§impl<'__de, __A> Decode<'__de, Text, __A> for Outputwhere
__A: Allocator,
impl<'__de, __A> Decode<'__de, Text, __A> for Outputwhere
__A: Allocator,
Source§const IS_BITWISE_DECODE: bool = false
const IS_BITWISE_DECODE: bool = false
Whether the type is packed. Packed types can be bitwise copied if the
representation of the serialization format is identical to the memory
layout of the type. Read more
Source§impl<'de> Deserialize<'de> for Output
impl<'de> Deserialize<'de> for Output
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 Encode<Binary> for Output
impl Encode<Binary> for Output
Source§const IS_BITWISE_ENCODE: bool = false
const IS_BITWISE_ENCODE: bool = false
Whether the type is packed. Packed types can be bitwise copied if the
representation of the serialization format is identical to the memory
layout of the type. Read more
Source§impl Encode<Text> for Output
impl Encode<Text> for Output
Source§const IS_BITWISE_ENCODE: bool = false
const IS_BITWISE_ENCODE: bool = false
Whether the type is packed. Packed types can be bitwise copied if the
representation of the serialization format is identical to the memory
layout of the type. Read more
impl Copy for Output
impl Eq for Output
impl StructuralPartialEq for Output
Auto Trait Implementations§
impl Freeze for Output
impl RefUnwindSafe for Output
impl Send for Output
impl Sync for Output
impl Unpin for Output
impl UnwindSafe for Output
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.