pub struct Id<'r> { /* private fields */ }
Expand description
An ObjectId
with access to a repository.
Implementations§
source§impl<'repo> Id<'repo>
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 index
only.
pub fn kind(&self) -> Kind
index
only.The kind of hash used for this instance.
sourcepub fn first_byte(&self) -> u8
Available on crate feature index
only.
pub fn first_byte(&self) -> u8
index
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 index
only.
pub fn as_bytes(&self) -> &[u8] ⓘ
index
only.Interpret this object id as raw byte slice.
sourcepub fn to_hex_with_len(&self, len: usize) -> HexDisplay<'_>
Available on crate feature index
only.
pub fn to_hex_with_len(&self, len: usize) -> HexDisplay<'_>
index
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 index
only.
pub fn to_hex(&self) -> HexDisplay<'_>
index
only.Return a type which displays this oid as hex in full.
sourcepub fn hex_to_buf(&self, buf: &mut [u8]) -> usize
Available on crate feature index
only.
pub fn hex_to_buf(&self, buf: &mut [u8]) -> usize
index
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<'repo> PartialEq<Id<'repo>> for Id<'repo>
impl<'repo> PartialEq<Id<'repo>> for Id<'repo>
source§impl<'repo> PartialEq<Id<'repo>> for ObjectId
impl<'repo> PartialEq<Id<'repo>> for ObjectId
source§impl<'repo> PartialEq<Object<'repo>> for Id<'repo>
impl<'repo> PartialEq<Object<'repo>> for Id<'repo>
source§impl<'repo> PartialEq<ObjectDetached> for Id<'repo>
impl<'repo> PartialEq<ObjectDetached> for Id<'repo>
source§fn eq(&self, other: &ObjectDetached) -> bool
fn eq(&self, other: &ObjectDetached) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<'repo> PartialEq<ObjectId> for Id<'repo>
impl<'repo> PartialEq<ObjectId> for Id<'repo>
source§impl<'a> PartialOrd<Id<'a>> for Id<'a>
impl<'a> PartialOrd<Id<'a>> for Id<'a>
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 more