pub struct ObjectId(/* private fields */);Expand description
A 20-byte SHA-1 object identifier.
Implementations§
Source§impl ObjectId
impl ObjectId
Sourcepub const fn zero() -> Self
pub const fn zero() -> Self
The all-zero object id (Git’s “null” OID).
Used for index placeholders such as intent-to-add entries and for special cases in plumbing output.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Construct from a 20-byte slice.
§Errors
Returns Error::InvalidObjectId when bytes is not exactly 20 bytes.
Sourcepub fn loose_prefix(&self) -> String
pub fn loose_prefix(&self) -> String
The two-character directory prefix used by the loose object store.
Returns the first two hex chars (e.g. "ab" for "ab3f…").
Sourcepub fn from_hex(s: &str) -> Result<Self>
pub fn from_hex(s: &str) -> Result<Self>
Parse an object ID from a hex string.
§Errors
Returns Error::InvalidObjectId if the string is not a valid
40-character hex OID.
Sourcepub fn loose_suffix(&self) -> String
pub fn loose_suffix(&self) -> String
The 38-character suffix used as the filename inside the loose prefix dir.
Trait Implementations§
Source§impl Ord for ObjectId
impl Ord for ObjectId
Source§impl PartialOrd for ObjectId
impl PartialOrd for ObjectId
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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more