use async_trait::async_trait;
use super::{RunPage, RunQuery, RunRecord, RunStoreError};
#[async_trait]
pub trait RunReader: Send + Sync {
async fn load_run(&self, run_id: &str) -> Result<Option<RunRecord>, RunStoreError>;
async fn list_runs(&self, query: &RunQuery) -> Result<RunPage, RunStoreError>;
async fn resolve_thread_id(&self, run_id: &str) -> Result<Option<String>, RunStoreError> {
Ok(self.load_run(run_id).await?.map(|r| r.thread_id))
}
async fn load_current_run(&self, thread_id: &str) -> Result<Option<RunRecord>, RunStoreError>;
}
#[async_trait]
pub trait RunWriter: RunReader {
async fn upsert_run(&self, record: &RunRecord) -> Result<(), RunStoreError>;
async fn delete_run(&self, run_id: &str) -> Result<(), RunStoreError>;
}
pub trait RunStore: RunWriter {}
impl<T: RunWriter + ?Sized> RunStore for T {}