pub enum ObjectId {
Sha1([u8; 20]),
}
Expand description
An owned hash identifying objects, most commonly Sha1
Variants§
Implementations§
source§impl ObjectId
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
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(&self, buf: &mut [u8]) -> usize
Available on crate feature excludes
only.
pub fn hex_to_buf(&self, buf: &mut [u8]) -> usize
excludes
only.Write ourselves to the out
in hexadecimal notation, returning the amount of written bytes.
Panics if the buffer isn’t big enough to hold twice as many bytes as the current binary size.
Trait Implementations§
source§impl<'de> Deserialize<'de> for ObjectId
impl<'de> Deserialize<'de> for ObjectId
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ObjectId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ObjectId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl ObjectIdExt for ObjectId
impl ObjectIdExt for ObjectId
source§impl Ord for ObjectId
impl Ord for ObjectId
source§impl PartialOrd for ObjectId
impl PartialOrd for ObjectId
source§impl Serialize for ObjectId
impl Serialize for ObjectId
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,
impl Copy for ObjectId
impl Eq for ObjectId
impl StructuralPartialEq for ObjectId
Auto Trait Implementations§
impl Freeze for ObjectId
impl RefUnwindSafe for ObjectId
impl Send for ObjectId
impl Sync for ObjectId
impl Unpin for ObjectId
impl UnwindSafe for ObjectId
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)