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
impl Repo
Sourcepub fn at(document: Document) -> Self
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).
Sourcepub fn folding(commits: &[Commit]) -> Result<Self, FoldError>
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.
Sourcepub fn fold_one(&mut self, commit: Commit) -> Result<&Document, FoldError>
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.
pub fn rev(&self) -> Rev
Sourcepub fn log(&self) -> &[Commit]
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.
Sourcepub fn revs_after(&self, rev: Rev) -> Vec<Rev>
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.
Sourcepub fn submit(
&mut self,
commit: Commit,
trail: &mut Trail,
) -> Result<Rev, FoldError>
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.
Sourcepub fn restore(&mut self, trail: &mut Trail, step: Restoring<'_>) -> Rev
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.