pub trait AtomicJournal: Send + Sync {
// Required method
fn append_atomic<'life0, 'life1, 'async_trait>(
&'life0 self,
run: RunId,
epoch: Epoch,
work: &'life1 dyn AtomicWork,
) -> Pin<Box<dyn Future<Output = Result<Vec<Record>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
A store whose own transaction a co-located resource can join.
Reached through JournalStore::atomic,
which answers None for a backend that cannot offer this. Absence is the
honest answer and it is checked where it is cheap — at registration, not at
commit.
Required Methods§
Sourcefn append_atomic<'life0, 'life1, 'async_trait>(
&'life0 self,
run: RunId,
epoch: Epoch,
work: &'life1 dyn AtomicWork,
) -> Pin<Box<dyn Future<Output = Result<Vec<Record>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn append_atomic<'life0, 'life1, 'async_trait>(
&'life0 self,
run: RunId,
epoch: Epoch,
work: &'life1 dyn AtomicWork,
) -> Pin<Box<dyn Future<Output = Result<Vec<Record>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run work and append what it returns, in one transaction, fenced by
epoch exactly as an ordinary append is.
The run is named rather than read from the records, because the fence is taken before the work runs. Deriving it afterwards would execute a displaced writer’s statements and only then discover it had no right to — harmless for a transaction, and a bad habit to build a fence on.
The fence is not optional here and not weaker: a displaced writer that could commit a resource change because it arrived wrapped in a transaction would be a fence with a hole in it shaped like this feature.
§Errors
StoreError::Fenced if the epoch has moved on, or whatever the work
or the append reports. Any error means nothing was committed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".