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