use crate::error::MbtError;
use crate::value::Value;
use crate::types::{RoleId, Arg};
use async_trait::async_trait;
pub trait StateGetter {
fn get_state(&self, key: &str) -> Result<Value, MbtError>;
}
pub trait SnapshotStateGetter {
fn snapshot(&self) -> Result<Vec<(String, Value)>, MbtError>;
}
pub trait Role {}
pub trait AsyncRole: Role + Send + Sync + 'static {}
impl<T: Role + Send + Sync + 'static> AsyncRole for T {}
#[async_trait]
pub trait Model: Send + Sync + 'static {
async fn init(&mut self) -> Result<(), MbtError>;
async fn cleanup(&mut self) -> Result<(), MbtError>;
}
#[async_trait]
pub trait DispatchModel: Send + Sync + 'static {
async fn execute(
&self,
role_id: &RoleId,
function_name: &str,
_args: &[Arg],
) -> Result<Value, MbtError>;
fn get_roles(&self) -> Result<Vec<RoleId>, MbtError>;
}