pub struct Sidecar<S: TileStore> { /* private fields */ }Expand description
The sidecar over a store.
Implementations§
Source§impl<S: TileStore> Sidecar<S>
impl<S: TileStore> Sidecar<S>
Sourcepub fn open(store: S) -> Result<Self, Error>
pub fn open(store: S) -> Result<Self, Error>
Opens the sidecar on store, taking the writer lock.
Sourcepub fn put(
&mut self,
path: &str,
bytes: &[u8],
meta: BTreeMap<String, String>,
) -> Result<u64, Error>
pub fn put( &mut self, path: &str, bytes: &[u8], meta: BTreeMap<String, String>, ) -> Result<u64, Error>
Records that path now holds bytes. The blob is written first,
once per content hash; the entry follows.
Sourcepub fn delete(
&mut self,
path: &str,
meta: BTreeMap<String, String>,
) -> Result<u64, Error>
pub fn delete( &mut self, path: &str, meta: BTreeMap<String, String>, ) -> Result<u64, Error>
Records that path is gone.
Sourcepub fn blob(&self, hex: &str) -> Result<Option<Vec<u8>>, Error>
pub fn blob(&self, hex: &str) -> Result<Option<Vec<u8>>, Error>
The bytes of the blob hex names, checked against the hash, or
nothing when the store lacks it.
Sourcepub fn change(&self, index: u64) -> Result<Option<Change>, Error>
pub fn change(&self, index: u64) -> Result<Option<Change>, Error>
The change at log index index, or nothing when the entry is a run
manifest or out of range.
Sourcepub fn history(&self, path: &str) -> Result<Vec<Found>, Error>
pub fn history(&self, path: &str) -> Result<Vec<Found>, Error>
Every change to path, oldest first, each with its proof.
Sourcepub fn under(&self, dir: &str) -> Result<Vec<Found>, Error>
pub fn under(&self, dir: &str) -> Result<Vec<Found>, Error>
Every change to a path under dir, in key order, each with its
proof. dir is a directory path without a trailing slash, or the
empty string for every path.
Sourcepub fn diff(&self, from: u64, to: u64) -> Result<Vec<(u64, Change)>, Error>
pub fn diff(&self, from: u64, to: u64) -> Result<Vec<(u64, Change)>, Error>
The changes with log index in from..to, in log order: what a
snapshot at to holds that one at from did not.
Sourcepub fn tree_at(
&self,
size: u64,
) -> Result<BTreeMap<String, (u64, Change)>, Error>
pub fn tree_at( &self, size: u64, ) -> Result<BTreeMap<String, (u64, Change)>, Error>
The tree as the first size entries leave it: each path’s latest
put, with the index that made it; a deleted path is absent.
Sourcepub fn include_checkpoint(
&mut self,
path: &str,
note: &Note,
trusted: &[Verifier],
meta: BTreeMap<String, String>,
) -> Result<u64, Error>
pub fn include_checkpoint( &mut self, path: &str, note: &Note, trusted: &[Verifier], meta: BTreeMap<String, String>, ) -> Result<u64, Error>
Logs a child project’s signed checkpoint under path, so this log’s
next checkpoint signs the child’s. The note has to carry a signature
from one of trusted, and it has to extend the child’s last logged
checkpoint: a smaller size, or the same size with another root, is
refused as an equivocation. The note is kept whole, so a reader
re-verifies it from the entry.
Sourcepub fn checkpoints(&self, path: &str) -> Result<Vec<(u64, Checkpoint)>, Error>
pub fn checkpoints(&self, path: &str) -> Result<Vec<(u64, Checkpoint)>, Error>
The child checkpoints logged under path, oldest first, each parsed
from the note the entry keeps.
Sourcepub fn snapshot(&mut self, signer: &Signer, origin: &str) -> Result<Note, Error>
pub fn snapshot(&mut self, signer: &Signer, origin: &str) -> Result<Note, Error>
Seals the unsealed tail into a run, when there is one, and signs the
log’s size and root as a checkpoint under origin.
Sourcepub fn compact(&mut self) -> Result<Compaction, Error>
pub fn compact(&mut self) -> Result<Compaction, Error>
Merges the live runs into one and logs it.
Source§impl<S: TileStore> Sidecar<S>
impl<S: TileStore> Sidecar<S>
Sourcepub fn sync_dir(
&mut self,
root: &Path,
skip: &[&str],
meta: &BTreeMap<String, String>,
) -> Result<Synced, Error>
pub fn sync_dir( &mut self, root: &Path, skip: &[&str], meta: &BTreeMap<String, String>, ) -> Result<Synced, Error>
Records the regular files under root against the tree the log
holds, the way etckeeper commits /etc: a file the log lacks or holds
with other bytes is a put, a path the log holds that the directory
lacks is a delete, and a file with the same bytes is left alone.
Every change carries meta, and all of them go in one batch after
their blobs. skip names entries at the top of root that are not
the project’s, the sidecar’s own directory among them. Symbolic
links are not followed and not recorded.