Struct git_hash::oid [−][src]
A borrowed reference to a hash identifying objects.
Future Proofing
In case we wish to support multiple hashes with the same length we cannot discriminate
using the slice length anymore. To make that work, we will use the high bits of the
internal bytes
slice length (a fat pointer, pointing to data and its length in bytes)
to encode additinoal information. Before accessing or returning the bytes, a new adjusted
slice will be constructed, while the high bits will be used to help resolving the
hash [
kind()][oid::kind()]
.
We expect to have quite a few bits available for such ‘conflict resolution’ as most hashes aren’t longer
than 64 bytes.
Implementations
impl oid
[src]
Conversion
impl oid
[src]
Access
pub fn kind(&self) -> Kind
[src]
The kind of hash used for this Digest
pub fn first_byte(&self) -> u8
[src]
The first byte of the hash, commonly used to partition a set of Id
s
pub fn as_bytes(&self) -> &[u8]
[src]
impl oid
[src]
Sha1 specific methods
pub fn to_sha1_hex(&self) -> [u8; 40]
[src]
Returns an array with a hexadecimal encoded version of the Sha1 hash this Id
represents.
Panics if this is not a Sha1 hash, as identifiable by [Id::kind()
].
pub fn sha1(&self) -> &[u8; 20]
[src]
Returns the bytes making up the Sha1.
Panics if this is not a Sha1 hash, as identifiable by [Id::kind()
].
pub fn null_sha1() -> &'static Self
[src]
Returns a Sha1 digest with all bytes being initialized to zero.
Trait Implementations
impl AsRef<oid> for &oid
[src]
impl AsRef<oid> for ObjectId
[src]
impl Borrow<oid> for ObjectId
[src]
impl Debug for oid
[src]
impl<'de: 'a, 'a> Deserialize<'de> for &'a oid
[src]
Manually created from a version that uses a slice, and we forcefully try to convert it into a borrowed array of the desired size Could be improved by fitting this into serde Unfortunately the serde::Deserialize derive wouldn’t work for borrowed arrays.
fn deserialize<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl Display for &oid
[src]
impl Eq for oid
[src]
impl From<&'_ oid> for ObjectId
[src]
impl<'a> From<&'a [u8; 20]> for &'a oid
[src]
impl Hash for oid
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for oid
[src]
fn cmp(&self, other: &oid) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<&'_ oid> for ObjectId
[src]
impl PartialEq<ObjectId> for &oid
[src]
fn eq(&self, other: &ObjectId) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<oid> for oid
[src]
impl PartialOrd<oid> for oid
[src]
fn partial_cmp(&self, other: &oid) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for oid
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,