bpm_engine_runtime/
engine.rs1use super::handler::{EngineContext, EventHandler};
2use super::pump::EventPump;
3use bpm_engine_core::EngineEvent;
4use bpm_engine_storage::TokenStore;
5use std::sync::Arc;
6
7pub struct Engine<S> {
8 store: Arc<S>,
9}
10
11impl<S> Engine<S>
12where
13 S: TokenStore + Send + Sync + 'static,
14{
15 pub fn new(store: Arc<S>) -> Self {
16 Self { store }
17 }
18
19 pub async fn tick(&self) -> anyhow::Result<()> {
20 let _ = &self.store;
24 Ok(())
25 }
26}
27
28pub struct BpmEngine {
30 pub handlers: Vec<Box<dyn EventHandler>>,
31}
32
33impl BpmEngine {
34 pub fn new(handlers: Vec<Box<dyn EventHandler>>) -> Self {
35 BpmEngine { handlers }
36 }
37
38 pub async fn run_async(&self, initial: EngineEvent, ctx: &mut EngineContext) {
40 EventPump::run_async(&self.handlers, initial, ctx).await;
41 }
42}