Skip to main content

Sidecar

Struct Sidecar 

Source
pub struct Sidecar<S: TileStore> { /* private fields */ }
Expand description

The sidecar over a store.

Implementations§

Source§

impl<S: TileStore> Sidecar<S>

Source

pub fn open(store: S) -> Result<Self, Error>

Opens the sidecar on store, taking the writer lock.

Source

pub fn log(&self) -> &Store<S>

The log underneath.

Source

pub fn size(&self) -> u64

Entries in the log, changes and run manifests together.

Source

pub fn root(&self) -> [u8; 32]

The root over the log.

Source

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.

Source

pub fn delete( &mut self, path: &str, meta: BTreeMap<String, String>, ) -> Result<u64, Error>

Records that path is gone.

Source

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.

Source

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.

Source

pub fn history(&self, path: &str) -> Result<Vec<Found>, Error>

Every change to path, oldest first, each with its proof.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn compact(&mut self) -> Result<Compaction, Error>

Merges the live runs into one and logs it.

Source§

impl<S: TileStore> Sidecar<S>

Source

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.

Auto Trait Implementations§

§

impl<S> Freeze for Sidecar<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for Sidecar<S>

§

impl<S> Send for Sidecar<S>
where S: Send,

§

impl<S> Sync for Sidecar<S>
where S: Sync,

§

impl<S> Unpin for Sidecar<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Sidecar<S>
where S: UnsafeUnpin,

§

impl<S> !UnwindSafe for Sidecar<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.