use std::sync::Arc;
use async_trait::async_trait;
use mf_model::{node_pool::NodePool, schema::Schema};
use mf_state::{
state::State,
transaction::{Command, Transaction},
};
use crate::{config::ForgeConfig, types::RuntimeOptions, ForgeResult};
#[async_trait]
pub trait RuntimeTrait: Send {
async fn dispatch(
&mut self,
transaction: Transaction,
) -> ForgeResult<()>;
async fn dispatch_with_meta(
&mut self,
transaction: Transaction,
description: String,
meta: serde_json::Value,
) -> ForgeResult<()>;
async fn command(
&mut self,
command: Arc<dyn Command>,
) -> ForgeResult<()>;
async fn command_with_meta(
&mut self,
command: Arc<dyn Command>,
description: String,
meta: serde_json::Value,
) -> ForgeResult<()>;
async fn get_state(&self) -> ForgeResult<Arc<State>>;
async fn get_tr(&self) -> ForgeResult<Transaction>;
async fn doc(&self) -> ForgeResult<Arc<NodePool>> {
Ok(self.get_state().await?.doc())
}
async fn get_schema(&self) -> ForgeResult<Arc<Schema>>;
async fn undo(&mut self) -> ForgeResult<()>;
async fn redo(&mut self) -> ForgeResult<()>;
async fn jump(
&mut self,
steps: isize,
) -> ForgeResult<()>;
fn get_config(&self) -> &ForgeConfig;
fn update_config(
&mut self,
config: ForgeConfig,
);
fn get_options(&self) -> &RuntimeOptions;
async fn destroy(&mut self) -> ForgeResult<()>;
}