pub trait ReadModelStore: Send + Sync {
// Required methods
fn upsert<'life0, 'async_trait>(
&'life0 self,
op: Upsert,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Option<Row>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn find_by<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
table: &'life1 str,
field: &'life2 str,
value: &'life3 Value,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Vec<Row>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
table: &'life1 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Vec<Row>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn truncate<'life0, 'life1, 'async_trait>(
&'life0 self,
table: &'life1 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Backend-agnostic storage for projection read models.
Implementations must be Send + Sync. Multiple projectors may share a
store instance (different tables in the same database). Interior
mutability (connection pools, Mutex, etc.) is expected.
Required Methods§
Sourcefn upsert<'life0, 'async_trait>(
&'life0 self,
op: Upsert,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn upsert<'life0, 'async_trait>(
&'life0 self,
op: Upsert,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert or update a row, version-gated.
Writes only if no row exists with the given key, or the existing row’s
version is strictly less than the incoming row’s version. Returns
Ok(()) whether or not the gate let the write through — the caller
(projector) does not need to distinguish “applied” from “skipped as
stale”, which matters for replay semantics.
Sourcefn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete a row by primary key. No-op if missing.
Sourcefn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Option<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Option<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetch a single row by primary key.
Sourcefn find_by<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
table: &'life1 str,
field: &'life2 str,
value: &'life3 Value,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Vec<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn find_by<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
table: &'life1 str,
field: &'life2 str,
value: &'life3 Value,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Vec<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Fetch all rows where field equals value. Used for secondary-index
lookups such as login-by-email. Backends may or may not have an index
on the field — the trait carries no guarantee.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".