pub struct OpLog { /* private fields */ }Implementations§
Source§impl OpLog
impl OpLog
pub fn open(root: &Path) -> Result<Self>
Sourcepub fn put(&self, rec: &OperationRecord) -> Result<()>
pub fn put(&self, rec: &OperationRecord) -> Result<()>
Persist a record. Idempotent on existing op_ids (the bytes must match by content addressing).
Crash safety: the tempfile’s data is fsync’d before rename,
so a successful return implies a durable file at the final
path. The containing directory is not fsync’d; on a crash
between rename and the directory’s metadata flush, the file
can be lost. For a content-addressed log this is acceptable
— a lost record can be re-derived from the same source — but
callers that also persist references to the op_id (e.g.
branch heads) should fsync those refs after put returns.
pub fn get(&self, op_id: &OpId) -> Result<Option<OperationRecord>>
Sourcepub fn walk_back(
&self,
head: &OpId,
limit: Option<usize>,
) -> Result<Vec<OperationRecord>>
pub fn walk_back( &self, head: &OpId, limit: Option<usize>, ) -> Result<Vec<OperationRecord>>
Walk parents transitively. Newest-first, BFS, dedup’d by op_id.
Stops at parentless ops or after limit records.
Sourcepub fn walk_forward(
&self,
head: &OpId,
limit: Option<usize>,
) -> Result<Vec<OperationRecord>>
pub fn walk_forward( &self, head: &OpId, limit: Option<usize>, ) -> Result<Vec<OperationRecord>>
Same set as walk_back but oldest-first. Used by branch_head for left-to-right transition replay.
Sourcepub fn lca(&self, a: &OpId, b: &OpId) -> Result<Option<OpId>>
pub fn lca(&self, a: &OpId, b: &OpId) -> Result<Option<OpId>>
Common ancestor of two op_ids in the DAG.
On tree-shaped histories and chain merges this is the
lowest common ancestor — the closest shared op. On
criss-cross merges (two ops each with two parents from
independent histories) there can be multiple
incomparable common ancestors; this picks one
deterministically (the first hit when traversing b’s
ancestors newest-first), but not via a recursive merge.
None if no shared ancestor exists.
Tier-1 merge in #129 covers linear and tree-shaped
histories; criss-cross resolution is deferred to a
future tier (Git’s recursive strategy is the reference).
Sourcepub fn list_all(&self) -> Result<Vec<OperationRecord>>
pub fn list_all(&self) -> Result<Vec<OperationRecord>>
Every record in the log. Order is whatever the directory
listing produces — undefined and not stable. Used by the
[crate::predicate] evaluator when no narrower candidate
set is available.