Struct git_repository::index::hash::Prefix
source · pub struct Prefix { /* private fields */ }
Expand description
An partial owned hash possibly identifying an object uniquely, whose non-prefix bytes are zeroed.
Implementations§
source§impl Prefix
impl Prefix
sourcepub const MIN_HEX_LEN: usize = 4usize
pub const MIN_HEX_LEN: usize = 4usize
The smallest allowed prefix length below which chances for collisions are too high even in small repositories.
sourcepub fn new(id: impl AsRef<oid>, hex_len: usize) -> Result<Prefix, Error>
pub fn new(id: impl AsRef<oid>, hex_len: usize) -> Result<Prefix, Error>
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
pub fn as_oid(&self) -> &oid
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
pub fn hex_len(&self) -> usize
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 PartialEq<Prefix> for Prefix
impl PartialEq<Prefix> for Prefix
source§impl PartialOrd<Prefix> for Prefix
impl PartialOrd<Prefix> for Prefix
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§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
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 StructuralEq for Prefix
impl StructuralPartialEq for Prefix
Auto Trait Implementations§
impl RefUnwindSafe for Prefix
impl Send for Prefix
impl Sync for Prefix
impl Unpin for Prefix
impl UnwindSafe for Prefix
Blanket Implementations§
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere T: Display,
§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
]. Read more