use crate::engine::instance::ProcessInstance;
use async_trait::async_trait;
use std::sync::Arc;
#[async_trait]
pub trait Repository: Send + Sync {
async fn save(&self, instance: Arc<ProcessInstance>) -> Result<(), RepositoryError>;
async fn get(&self, instance_id: &str) -> Result<Option<Arc<ProcessInstance>>, RepositoryError>;
async fn delete(&self, instance_id: &str) -> Result<(), RepositoryError>;
async fn list_ids(&self) -> Result<Vec<String>, RepositoryError>;
async fn exists(&self, instance_id: &str) -> Result<bool, RepositoryError> {
Ok(self.get(instance_id).await?.is_some())
}
}
#[derive(Debug, thiserror::Error)]
pub enum RepositoryError {
#[error("Repository operation failed: {0}")]
OperationFailed(String),
#[error("Instance not found: {0}")]
NotFound(String),
#[error("Storage error: {0}")]
StorageError(String),
}