pub trait ChangeIdIndex: Send + Sync {
// Required methods
fn resolve_prefix(
&self,
prefix: &HexPrefix,
) -> PrefixResolution<Vec<CommitId>>;
fn shortest_unique_prefix_len(&self, change_id: &ChangeId) -> usize;
}
Expand description
Defines the interface for types that provide an index of the commits in a
repository by ChangeId
.
Required Methods§
Sourcefn resolve_prefix(&self, prefix: &HexPrefix) -> PrefixResolution<Vec<CommitId>>
fn resolve_prefix(&self, prefix: &HexPrefix) -> PrefixResolution<Vec<CommitId>>
Resolve an unambiguous change ID prefix to the commit IDs in the index.
The order of the returned commit IDs is unspecified.
Sourcefn shortest_unique_prefix_len(&self, change_id: &ChangeId) -> usize
fn shortest_unique_prefix_len(&self, change_id: &ChangeId) -> usize
This function returns the shortest length of a prefix of key
that
disambiguates it from every other key in the index.
The length returned is a number of hexadecimal digits.
This has some properties that we do not currently make much use of:
-
The algorithm works even if
key
itself is not in the index. -
In the special case when there are keys in the trie for which our
key
is an exact prefix, returnskey.len() + 1
. Conceptually, in order to disambiguate, you need every letter of the key and the additional fact that it’s the entire key). This case is extremely unlikely for hashes with 12+ hexadecimal characters.