pub struct Id<'r> {
pub repo: &'r Repository,
/* private fields */
}Expand description
An ObjectId with access to a repository.
Fields§
§repo: &'r RepositoryThe owning repository.
Implementations§
Source§impl<'repo> Id<'repo>
An object id infused with a Repository.
impl<'repo> Id<'repo>
An object id infused with a Repository.
Sourcepub fn header(&self) -> Result<Header, Error>
pub fn header(&self) -> Result<Header, Error>
Find the header associated with this object id, or an error if it doesn’t exist.
Use this method if there is no interest in the contents of the object, which generally is much faster to obtain.
Sourcepub fn try_header(&self) -> Result<Option<Header>, Error>
pub fn try_header(&self) -> Result<Option<Header>, Error>
Find the header associated with this object id, or return None if it doesn’t exist.
Use this method if there is no interest in the contents of the object, which generally is much faster to obtain.
Sourcepub fn shorten(&self) -> Result<Prefix, Error>
pub fn shorten(&self) -> Result<Prefix, Error>
Turn this object id into a shortened id with a length in hex as configured by core.abbrev.
Sourcepub fn shorten_or_id(&self) -> Prefix
pub fn shorten_or_id(&self) -> Prefix
Turn this object id into a shortened id with a length in hex as configured by core.abbrev, or default
to a prefix which equals our id in the unlikely error case.
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 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.
Sourcepub fn write_hex_to(&self, out: &mut dyn Write) -> Result<(), Error>
Available on crate feature excludes only.
pub fn write_hex_to(&self, out: &mut dyn Write) -> Result<(), Error>
excludes only.Write ourselves to out in hexadecimal notation.
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.
Trait Implementations§
Source§impl<'repo> PartialEq<Object<'repo>> for Id<'repo>
impl<'repo> PartialEq<Object<'repo>> for Id<'repo>
Source§impl PartialEq<ObjectDetached> for Id<'_>
impl PartialEq<ObjectDetached> for Id<'_>
Source§fn eq(&self, other: &ObjectDetached) -> bool
fn eq(&self, other: &ObjectDetached) -> bool
self and other values to be equal, and is used by ==.