pub struct Oid { /* private fields */ }Expand description
A Git object ID (SHA-1 hash).
This type represents a 20-byte SHA-1 hash that uniquely identifies a Git object (blob, tree, commit, or tag).
Implementations§
Source§impl Oid
impl Oid
Sourcepub fn from_hex(hex: &str) -> Result<Self>
pub fn from_hex(hex: &str) -> Result<Self>
Creates an Oid from a 40-character hexadecimal string.
§Arguments
hex- A 40-character hexadecimal string (case-insensitive).
§Returns
The Oid on success, or Error::InvalidOid if the string is invalid.
§Examples
use zerogit::objects::Oid;
let oid = Oid::from_hex("da39a3ee5e6b4b0d3255bfef95601890afd80709").unwrap();
assert_eq!(oid.to_hex(), "da39a3ee5e6b4b0d3255bfef95601890afd80709");Sourcepub fn from_bytes(bytes: [u8; 20]) -> Self
pub fn from_bytes(bytes: [u8; 20]) -> Self
Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Returns the hexadecimal string representation of this Oid.
The returned string is always lowercase and 40 characters long.
Trait Implementations§
Source§impl Ord for Oid
impl Ord for Oid
Source§impl PartialOrd for Oid
impl PartialOrd for Oid
impl Copy for Oid
impl Eq for Oid
impl StructuralPartialEq for Oid
Auto Trait Implementations§
impl Freeze for Oid
impl RefUnwindSafe for Oid
impl Send for Oid
impl Sync for Oid
impl Unpin for Oid
impl UnwindSafe for Oid
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