pub struct MemoryLedger { /* private fields */ }Expand description
A ledger held in process memory. Cloning it copies the ledger as it is now.
Implementations§
Source§impl MemoryLedger
impl MemoryLedger
Trait Implementations§
Source§impl Clone for MemoryLedger
impl Clone for MemoryLedger
Source§impl Debug for MemoryLedger
impl Debug for MemoryLedger
Source§impl Default for MemoryLedger
impl Default for MemoryLedger
Source§impl LedgerStore for MemoryLedger
impl LedgerStore for MemoryLedger
Source§fn ensure(&self, _prefix: &str) -> Result<(), ReplicaError>
fn ensure(&self, _prefix: &str) -> Result<(), ReplicaError>
Creates the ledger’s tables if they do not exist. Idempotent.
Source§fn write(
&self,
prefix: &str,
work: &mut dyn FnMut(&mut dyn LedgerTx) -> Result<(), ReplicaError>,
) -> Result<(), ReplicaError>
fn write( &self, prefix: &str, work: &mut dyn FnMut(&mut dyn LedgerTx) -> Result<(), ReplicaError>, ) -> Result<(), ReplicaError>
Runs
work in one write transaction: everything it wrote is committed when
it returns Ok, and nothing is when it returns Err. Two writers on the
same ledger never interleave. work is called exactly once.Source§fn read_record(
&self,
prefix: &str,
collection: &str,
) -> Result<Option<CollectionRecord>, ReplicaError>
fn read_record( &self, prefix: &str, collection: &str, ) -> Result<Option<CollectionRecord>, ReplicaError>
The collection’s header as last committed, read without taking the write
lock:
head() and a pull answered “nothing new” need nothing else. The
default reads it inside LedgerStore::write; a store with a cheaper
read overrides it.Auto Trait Implementations§
impl !Freeze for MemoryLedger
impl Forget for MemoryLedger
impl Move for MemoryLedger
impl RefUnwindSafe for MemoryLedger
impl Send for MemoryLedger
impl Sync for MemoryLedger
impl Unpin for MemoryLedger
impl UnsafeUnpin for MemoryLedger
impl UnwindSafe for MemoryLedger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more