Mercurial > hg-stable
changeset 44256:3fb39dc2e356
rust-revlog: a trait for the revlog index
As explained in the doc comment, this is the minimum needed
for our immediate concern, which is to implement a nodemap
in Rust.
The trait will be later implemented in `hg-cpython` by the
index Python object implemented in C, thanks to exposition
of the corresponding functions as a capsule.
The `None` return cases in `node()` match what the `index_node()`
C function does.
Differential Revision: https://phab.mercurial-scm.org/D7789
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Wed, 22 Jan 2020 16:35:56 +0100 |
parents | d84420232492 |
children | 9896a8d0d3d2 |
files | rust/hg-core/src/revlog.rs |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog.rs Fri Jan 24 17:10:45 2020 -0800 +++ b/rust/hg-core/src/revlog.rs Wed Jan 22 16:35:56 2020 +0100 @@ -40,3 +40,17 @@ ParentOutOfRange(Revision), WorkingDirectoryUnsupported, } + +/// The Mercurial Revlog Index +/// +/// This is currently limited to the minimal interface that is needed for +/// the [`nodemap`](nodemap/index.html) module +pub trait RevlogIndex { + /// Total number of Revisions referenced in this index + fn len(&self) -> usize; + + /// Return a reference to the Node or `None` if rev is out of bounds + /// + /// `NULL_REVISION` is not considered to be out of bounds. + fn node(&self, rev: Revision) -> Option<&Node>; +}