pub trait JournalStore: Send + Sync {
// Required methods
fn capabilities(&self) -> JournalCapabilities;
fn append(
&self,
actor: &NamedNode,
expected: Position,
entries: &[Entry],
meta: &AppendMeta,
) -> Result<Position, AppendError>;
fn read(
&self,
actor: &NamedNode,
from: Position,
) -> Result<Vec<JournalRecord>, StoreError>;
fn head(&self, actor: &NamedNode) -> Result<Position, StoreError>;
fn actors(&self) -> Result<Vec<NamedNode>, StoreError>;
// Provided method
fn supports_fencing(&self) -> bool { ... }
}Expand description
A journal store: per actor address, a linearizable, all-or-nothing append at an expected position, and reads from a position.
Required Methods§
Sourcefn capabilities(&self) -> JournalCapabilities
fn capabilities(&self) -> JournalCapabilities
What the store supports beyond compare-and-set.
Sourcefn append(
&self,
actor: &NamedNode,
expected: Position,
entries: &[Entry],
meta: &AppendMeta,
) -> Result<Position, AppendError>
fn append( &self, actor: &NamedNode, expected: Position, entries: &[Entry], meta: &AppendMeta, ) -> Result<Position, AppendError>
Appends entries to actor’s journal if, and only if, its last entry is at expected.
On success the entries are at expected + 1 ..= expected + entries.len() and the new
head is returned. On any error nothing is written: no entry, no state change and no
fencing epoch. Appends for one actor are linearizable.
§Errors
AppendError::Conflict when the journal is elsewhere, AppendError::Fenced for a
stale fencing epoch, AppendError::Unsupported for metadata the store does not
support, AppendError::Invalid for malformed entries, AppendError::Storage when
the store fails.
Sourcefn read(
&self,
actor: &NamedNode,
from: Position,
) -> Result<Vec<JournalRecord>, StoreError>
fn read( &self, actor: &NamedNode, from: Position, ) -> Result<Vec<JournalRecord>, StoreError>
The entries of actor’s journal from position from (inclusive; 0 reads from the
start) to the head, in order.
§Errors
StoreError when the store fails.
Sourcefn head(&self, actor: &NamedNode) -> Result<Position, StoreError>
fn head(&self, actor: &NamedNode) -> Result<Position, StoreError>
The position of actor’s last entry, 0 for an empty journal.
§Errors
StoreError when the store fails.
Provided Methods§
Sourcefn supports_fencing(&self) -> bool
fn supports_fencing(&self) -> bool
True when the store enforces fencing tokens.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".