pub trait LedgerTx {
// Required methods
fn record(
&mut self,
collection: &str,
) -> Result<Option<CollectionRecord>, ReplicaError>;
fn put_record(
&mut self,
collection: &str,
record: &CollectionRecord,
) -> Result<(), ReplicaError>;
fn entry(
&mut self,
collection: &str,
key: &str,
) -> Result<Option<LedgerEntry>, ReplicaError>;
fn entries(
&mut self,
collection: &str,
) -> Result<Vec<LedgerEntry>, ReplicaError>;
fn put_entry(
&mut self,
collection: &str,
entry: &LedgerEntry,
) -> Result<(), ReplicaError>;
fn delete_entry(
&mut self,
collection: &str,
key: &str,
) -> Result<(), ReplicaError>;
fn changes_after(
&mut self,
collection: &str,
version: u64,
limit: usize,
) -> Result<Vec<LedgerEntry>, ReplicaError>;
fn live_after(
&mut self,
collection: &str,
after: Option<&str>,
limit: usize,
) -> Result<Vec<LedgerEntry>, ReplicaError>;
fn prune_tombstones(
&mut self,
collection: &str,
changed_before: u64,
keep: u64,
) -> Result<Pruned, ReplicaError>;
}Expand description
Ledger reads and writes inside one write transaction. Keys sort by their
UTF-8 bytes (SQLite’s BINARY collation, Rust’s str order).
Required Methods§
Sourcefn record(
&mut self,
collection: &str,
) -> Result<Option<CollectionRecord>, ReplicaError>
fn record( &mut self, collection: &str, ) -> Result<Option<CollectionRecord>, ReplicaError>
The collection’s header, or None before its first write.
Sourcefn put_record(
&mut self,
collection: &str,
record: &CollectionRecord,
) -> Result<(), ReplicaError>
fn put_record( &mut self, collection: &str, record: &CollectionRecord, ) -> Result<(), ReplicaError>
Creates or replaces the collection’s header.
Sourcefn entry(
&mut self,
collection: &str,
key: &str,
) -> Result<Option<LedgerEntry>, ReplicaError>
fn entry( &mut self, collection: &str, key: &str, ) -> Result<Option<LedgerEntry>, ReplicaError>
The entry of one key, tombstone or not.
Sourcefn entries(
&mut self,
collection: &str,
) -> Result<Vec<LedgerEntry>, ReplicaError>
fn entries( &mut self, collection: &str, ) -> Result<Vec<LedgerEntry>, ReplicaError>
Every entry, tombstones included, in key order.
Sourcefn put_entry(
&mut self,
collection: &str,
entry: &LedgerEntry,
) -> Result<(), ReplicaError>
fn put_entry( &mut self, collection: &str, entry: &LedgerEntry, ) -> Result<(), ReplicaError>
Creates or replaces the entry of entry.key.
Sourcefn delete_entry(
&mut self,
collection: &str,
key: &str,
) -> Result<(), ReplicaError>
fn delete_entry( &mut self, collection: &str, key: &str, ) -> Result<(), ReplicaError>
Removes the entry of one key (a tombstone dropped by a rotation).
Sourcefn changes_after(
&mut self,
collection: &str,
version: u64,
limit: usize,
) -> Result<Vec<LedgerEntry>, ReplicaError>
fn changes_after( &mut self, collection: &str, version: u64, limit: usize, ) -> Result<Vec<LedgerEntry>, ReplicaError>
Entries (tombstones included) whose version is above version, in
version order, at most limit.
Sourcefn live_after(
&mut self,
collection: &str,
after: Option<&str>,
limit: usize,
) -> Result<Vec<LedgerEntry>, ReplicaError>
fn live_after( &mut self, collection: &str, after: Option<&str>, limit: usize, ) -> Result<Vec<LedgerEntry>, ReplicaError>
Live entries whose key sorts after after (all of them when None), in
key order, at most limit.
Sourcefn prune_tombstones(
&mut self,
collection: &str,
changed_before: u64,
keep: u64,
) -> Result<Pruned, ReplicaError>
fn prune_tombstones( &mut self, collection: &str, changed_before: u64, keep: u64, ) -> Result<Pruned, ReplicaError>
Removes the tombstones that changed before changed_before (unix ms), and
all but the keep newest (by version) of the rest. Its cost should follow
the tombstones, not the live rows: it runs on every write.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".