pub trait StoragePort: Send + Sync {
// Required methods
fn store<'life0, 'async_trait>(
&'life0 self,
record: StorageRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<StorageRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
pipeline_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<StorageRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Port: persist and retrieve StorageRecords produced by pipelines.
§Example
use stygian_graph::ports::storage::{StoragePort, StorageRecord};
use serde_json::json;
async fn run<S: StoragePort>(storage: &S) {
let r = StorageRecord::new("pipe-1", "fetch", json!({"url": "https://example.com"}));
storage.store(r.clone()).await.unwrap();
let fetched = storage.retrieve(&r.id).await.unwrap().unwrap();
assert_eq!(fetched.id, r.id);
}Required Methods§
Sourcefn store<'life0, 'async_trait>(
&'life0 self,
record: StorageRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn store<'life0, 'async_trait>(
&'life0 self,
record: StorageRecord,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<StorageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn retrieve<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<StorageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a record by ID. Returns None if not found.
§Example
let maybe = s.retrieve("some-id").await.unwrap();