use crate::context::ReachableContext;
use crate::interruptor::{InterruptionLevel, Interruptor};
use async_trait::async_trait;
use std::ops::DerefMut;
#[async_trait]
pub trait Runtime: Send + 'static {
fn get_interruptor(&mut self) -> Box<dyn Interruptor>;
fn interruption_level(&self) -> InterruptionLevel {
InterruptionLevel::EVENT
}
async fn routine(&mut self);
}
pub trait InteractiveRuntime: Runtime {
type Context: ReachableContext;
fn address(&self) -> <Self::Context as ReachableContext>::Address;
}
#[async_trait]
impl Runtime for Box<dyn Runtime> {
fn get_interruptor(&mut self) -> Box<dyn Interruptor> {
self.deref_mut().get_interruptor()
}
async fn routine(&mut self) {
self.deref_mut().routine().await
}
}