Skip to main content

Repo

Struct Repo 

Source
pub struct Repo {
    document: Document,
    log: Vec<Commit>,
}
Expand description

The document and everything that writes it. A commit is folded and appended inside Self::submit or Self::restore, which are the only doors: there is no queue, no pending head, and no rev the caller can hold that the log does not.

The Trail a session steps through is beside this rather than in it (docs/log-vs-snapshot.md): what a step adopts is a document this type cannot reach on its own — a rev copy on disk, or a fold of a prefix of its own log — so the session owns both and hands them to each other.

Fields§

§document: Document§log: Vec<Commit>

Implementations§

Source§

impl Repo

Source

pub fn at(document: Document) -> Self

A repo standing on a document somebody else read — the head rev file a container opens on. Its log is this session’s own commits and starts empty: what came before is on disk, in rows and rev files, not in memory (docs/log-vs-snapshot.md).

Source

pub fn folding(commits: &[Commit]) -> Result<Self, FoldError>

Fold commits into a fresh repo, trailing nothing — a log that is already the document’s past, not a session’s edits.

§Errors

The fold’s refusal, naming the first commit this build will not take.

Source

pub fn fold_one(&mut self, commit: Commit) -> Result<&Document, FoldError>

Fold one more commit of the document’s past in, trailing nothing, and hand back what it folded to.

The returned document is what makes a verified replay one fold instead of two: the durable log stamps every record with the document it produced, and a loader that could not see the intermediate values would have to fold once to check them and again to build the repo.

§Errors

The fold’s refusal, leaving the repo as it stood.

Source

pub fn document(&self) -> &Document

What the editor draws.

Source

pub fn rev(&self) -> Rev

Source

pub fn log(&self) -> &[Commit]

The whole history, oldest first. log[i] holds Rev(i + 1) — contiguous because a refused commit consumes no rev, which is what lets the log be a Vec.

Source

pub fn revs_after(&self, rev: Rev) -> Vec<Rev>

The revs assigned after rev, oldest first — for a caller whose own history owes a step to each commit this repo has taken since it last looked. Empty for a rev at or beyond the head, which is what lets a caller carry a watermark across a document swap without arithmetic of its own.

Source

pub fn submit( &mut self, commit: Commit, trail: &mut Trail, ) -> Result<Rev, FoldError>

Fold, append, and record the edit on trail, in that order: a refused commit consumes no rev and leaves neither the log nor the trail touched.

The trail comes in rather than living here so that an edit cannot be logged without standing on it — Self::fold_one is the door for a past nobody may take back.

§Errors

The fold’s refusal.

Source

pub fn restore(&mut self, trail: &mut Trail, step: Restoring<'_>) -> Rev

Take the step entry names: adopt target — the document the session stood on before the record at entry.rev was written — and log it as a commit of its own, so a step back stays in the history rather than erasing what it crossed.

The commit carries no ops. A rev was validated by the fold when it was written, so restoring it needs no second fold and no inverse to build one from (docs/log-vs-snapshot.md): what a step records is label, which the caller reads off the record it is moving.

The adopted document keeps the one thing a session accumulates rather than holds — the allocator’s marks, which must never fall (see Document::restored_at). Payloads it does not: they live in the store, and a rev that references one gets it back when it is read.

Trait Implementations§

Source§

impl Default for Repo

Source§

fn default() -> Repo

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Repo

§

impl RefUnwindSafe for Repo

§

impl Send for Repo

§

impl Sync for Repo

§

impl Unpin for Repo

§

impl UnsafeUnpin for Repo

§

impl UnwindSafe for Repo

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, 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.