From patchwork Mon Jan 27 15:49:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7789: rust-revlog: a trait for the revlog index From: phabricator X-Patchwork-Id: 44682 Message-Id: <0525d16bbe0b65279e60409248a74178@localhost.localdomain> To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 27 Jan 2020 15:49:28 +0000 gracinet updated this revision to Diff 19629. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7789?vs=19038&id=19629 BRANCH default CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7789/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7789 AFFECTED FILES rust/hg-core/src/revlog.rs CHANGE DETAILS To: gracinet, #hg-reviewers, martinvonz Cc: martinvonz, durin42, kevincox, mercurial-devel diff --git a/rust/hg-core/src/revlog.rs b/rust/hg-core/src/revlog.rs --- a/rust/hg-core/src/revlog.rs +++ b/rust/hg-core/src/revlog.rs @@ -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>; +}