pub enum ObjectId {
Sha1([u8; 20]),
}Expand description
An owned hash identifying objects, most commonly Sha1
Variants§
Implementations§
Source§impl ObjectId
Access and conversion
impl ObjectId
Access and conversion
Sourcepub fn kind(&self) -> Kind
Available on crate feature excludes only.
pub fn kind(&self) -> Kind
excludes only.Returns the kind of hash used in this instance.
Sourcepub fn as_slice(&self) -> &[u8] ⓘ
Available on crate feature excludes only.
pub fn as_slice(&self) -> &[u8] ⓘ
excludes only.Return the raw byte slice representing this hash.
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Available on crate feature excludes only.
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
excludes only.Return the raw mutable byte slice representing this hash.
Sourcepub const fn empty_blob(hash: Kind) -> ObjectId
Available on crate feature excludes only.
pub const fn empty_blob(hash: Kind) -> ObjectId
excludes only.The hash of an empty blob.
Sourcepub const fn empty_tree(hash: Kind) -> ObjectId
Available on crate feature excludes only.
pub const fn empty_tree(hash: Kind) -> ObjectId
excludes only.The hash of an empty tree.
Sourcepub const fn null(kind: Kind) -> ObjectId
Available on crate feature excludes only.
pub const fn null(kind: Kind) -> ObjectId
excludes only.Returns an instances whose bytes are all zero.
Sourcepub fn is_null(&self) -> bool
Available on crate feature excludes only.
pub fn is_null(&self) -> bool
excludes only.Returns true if this hash consists of all null bytes.
Sourcepub fn is_empty_blob(&self) -> bool
Available on crate feature excludes only.
pub fn is_empty_blob(&self) -> bool
excludes only.Returns true if this hash is equal to an empty blob.
Sourcepub fn is_empty_tree(&self) -> bool
Available on crate feature excludes only.
pub fn is_empty_tree(&self) -> bool
excludes only.Returns true if this hash is equal to an empty tree.
Source§impl ObjectId
Lifecycle
impl ObjectId
Lifecycle
Sourcepub fn from_bytes_or_panic(bytes: &[u8]) -> ObjectId
Available on crate feature excludes only.
pub fn from_bytes_or_panic(bytes: &[u8]) -> ObjectId
excludes only.Convert bytes into an owned object Id or panic if the slice length doesn’t indicate a supported hash.
Use Self::try_from(bytes) for a fallible version.
impl ObjectId
Sha1 hash specific methods
Methods from Deref<Target = oid>§
Sourcepub fn kind(&self) -> Kind
Available on crate feature excludes only.
pub fn kind(&self) -> Kind
excludes only.The kind of hash used for this instance.
Sourcepub fn first_byte(&self) -> u8
Available on crate feature excludes only.
pub fn first_byte(&self) -> u8
excludes only.The first byte of the hash, commonly used to partition a set of object ids.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
Available on crate feature excludes only.
pub fn as_bytes(&self) -> &[u8] ⓘ
excludes only.Interpret this object id as raw byte slice.
Sourcepub fn to_hex_with_len(&self, len: usize) -> HexDisplay<'_>
Available on crate feature excludes only.
pub fn to_hex_with_len(&self, len: usize) -> HexDisplay<'_>
excludes only.Return a type which can display itself in hexadecimal form with the len amount of characters.
Sourcepub fn to_hex(&self) -> HexDisplay<'_>
Available on crate feature excludes only.
pub fn to_hex(&self) -> HexDisplay<'_>
excludes only.Return a type which displays this oid as hex in full.
Sourcepub fn is_null(&self) -> bool
Available on crate feature excludes only.
pub fn is_null(&self) -> bool
excludes only.Returns true if this hash consists of all null bytes.
Sourcepub fn hex_to_buf<'a>(&self, buf: &'a mut [u8]) -> &'a mut str
Available on crate feature excludes only.
pub fn hex_to_buf<'a>(&self, buf: &'a mut [u8]) -> &'a mut str
excludes only.Write ourselves to the out in hexadecimal notation, returning the hex-string ready for display.
Panics if the buffer isn’t big enough to hold twice as many bytes as the current binary size.