bpmn_engine/repository/
traits.rs1use crate::engine::instance::ProcessInstance;
6use async_trait::async_trait;
7use std::sync::Arc;
8
9#[async_trait]
14pub trait Repository: Send + Sync {
15 async fn save(&self, instance: Arc<ProcessInstance>) -> Result<(), RepositoryError>;
17
18 async fn get(&self, instance_id: &str) -> Result<Option<Arc<ProcessInstance>>, RepositoryError>;
20
21 async fn delete(&self, instance_id: &str) -> Result<(), RepositoryError>;
23
24 async fn list_ids(&self) -> Result<Vec<String>, RepositoryError>;
26
27 async fn exists(&self, instance_id: &str) -> Result<bool, RepositoryError> {
29 Ok(self.get(instance_id).await?.is_some())
30 }
31}
32
33#[derive(Debug, thiserror::Error)]
35pub enum RepositoryError {
36 #[error("Repository operation failed: {0}")]
37 OperationFailed(String),
38 #[error("Instance not found: {0}")]
39 NotFound(String),
40 #[error("Storage error: {0}")]
41 StorageError(String),
42}
43