pub struct Prefix { /* private fields */ }index only.Expand description
A partial, owned hash possibly identifying an object uniquely, whose non-prefix bytes are zeroed.
An example would 0000000000000000000000000000000032bd3242, where 32bd3242 is the prefix,
which would be able to match all hashes that start with 32bd3242.
Implementations§
Source§impl Prefix
impl Prefix
Sourcepub const MIN_HEX_LEN: usize = 4usize
Available on crate feature excludes only.
pub const MIN_HEX_LEN: usize = 4usize
excludes only.The smallest allowed prefix length below which chances for collisions are too high even in small repositories.
Sourcepub fn new(id: &oid, hex_len: usize) -> Result<Prefix, Error>
Available on crate feature excludes only.
pub fn new(id: &oid, hex_len: usize) -> Result<Prefix, Error>
excludes only.Create a new instance by taking a full id as input and truncating it to hex_len.
For instance, with hex_len of 7 the resulting prefix is 3.5 bytes, or 3 bytes and 4 bits
wide, with all other bytes and bits set to zero.
Sourcepub fn as_oid(&self) -> &oid
Available on crate feature excludes only.
pub fn as_oid(&self) -> &oid
excludes only.Returns the prefix as object id.
Note that it may be deceptive to use given that it looks like a full object id, even though its post-prefix bytes/bits are set to zero.
Sourcepub fn hex_len(&self) -> usize
Available on crate feature excludes only.
pub fn hex_len(&self) -> usize
excludes only.Return the amount of hexadecimal characters that are set in the prefix.
This gives the prefix a granularity of 4 bits.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Prefix
impl<'de> Deserialize<'de> for Prefix
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Prefix, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Prefix, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Prefix
impl Ord for Prefix
Source§impl PartialOrd for Prefix
impl PartialOrd for Prefix
Source§impl Serialize for Prefix
impl Serialize for Prefix
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl TryFrom<&str> for Prefix
Create an instance from the given hexadecimal prefix, e.g. 35e77c16 would yield a Prefix
with hex_len() = 8.
impl TryFrom<&str> for Prefix
Create an instance from the given hexadecimal prefix, e.g. 35e77c16 would yield a Prefix
with hex_len() = 8.
impl Copy for Prefix
impl Eq for Prefix
impl StructuralPartialEq for Prefix
Auto Trait Implementations§
impl Freeze for Prefix
impl RefUnwindSafe for Prefix
impl Send for Prefix
impl Sync for Prefix
impl Unpin for Prefix
impl UnwindSafe for Prefix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.