rune/runtime/
awaited.rs
1use crate::runtime::{Future, Output, Select, Vm, VmResult};
2
3#[derive(Debug)]
5pub(crate) enum Awaited {
6 Future(Future, Output),
8 Select(Select, Output),
10}
11
12impl Awaited {
13 pub(crate) async fn into_vm(self, vm: &mut Vm) -> VmResult<()> {
15 match self {
16 Self::Future(future, out) => {
17 let value = vm_try!(future.await.with_vm(vm));
18 vm_try!(out.store(vm.stack_mut(), value));
19 }
20 Self::Select(select, value_addr) => {
21 let (ip, value) = vm_try!(select.await.with_vm(vm));
22 vm.set_ip(ip);
23 vm_try!(value_addr.store(vm.stack_mut(), || value));
24 }
25 }
26
27 VmResult::Ok(())
28 }
29}