Enum git_hash::ObjectId[][src]

pub enum ObjectId {
    Sha1([u8; 20]),
}

An owned hash identifying objects, most commonly Sha1

Variants

Sha1([u8; 20])

Implementations

impl ObjectId[src]

Access and conversion

pub fn kind(&self) -> Kind[src]

Returns the kind of hash used in this Id

pub fn as_slice(&self) -> &[u8][src]

Return the raw byte slice representing this hash

pub fn as_mut_slice(&mut self) -> &mut [u8][src]

Return the raw mutable byte slice representing this hash

pub fn write_hex_to(&self, out: impl Write) -> Result<()>[src]

Write ourselves to out in hexadecimal notation

impl ObjectId[src]

Sha1 hash specific methods

pub fn sha1(&self) -> &[u8; 20][src]

Returns ourselves as slice of 20 bytes.

Panics if this instance is not a sha1 hash.

pub fn to_sha1_hex(&self) -> [u8; 40][src]

Return ourselves as array of 40 hexadecimal bytes.

Panics if this instance is not a sha1 hash.

pub fn to_sha1_hex_string(&self) -> String[src]

Return ourselves as hexadecimal string with a length of 40 bytes.

Panics if this instance is not a sha1 hash.

pub fn new_sha1(id: [u8; 20]) -> Self[src]

Instantiate an Digest from 20 bytes of a Sha1 digest.

pub fn from_20_bytes(b: &[u8]) -> ObjectId[src]

Instantiate an Digest from a slice 20 borrowed bytes of a Sha1 digest.

Panics of the slice doesn’t have a length of 20.

pub fn from_borrowed_sha1(b: &[u8; 20]) -> ObjectId[src]

Instantiate an Digest from a borrowed array of 20 bytes of a Sha1 digest.

pub fn null_sha1() -> ObjectId[src]

Returns an Digest representing a Sha1 with whose memory is zeroed.

impl ObjectId[src]

Hash decoding

pub fn from_hex(buffer: &[u8]) -> Result<ObjectId, Error>[src]

Create an instance from a buffer of 40 bytes encoded with hexadecimal notation.

Such a buffer can be obtained using [write_hex_to(buffer)][Id::write_hex_to()]

Methods from Deref<Target = oid>

pub fn kind(&self) -> Kind[src]

The kind of hash used for this Digest

pub fn first_byte(&self) -> u8[src]

The first byte of the hash, commonly used to partition a set of Ids

pub fn as_bytes(&self) -> &[u8][src]

pub fn to_sha1_hex(&self) -> [u8; 40][src]

Returns an array with a hexadecimal encoded version of the Sha1 hash this Id represents.

Panics if this is not a Sha1 hash, as identifiable by [Id::kind()].

pub fn sha1(&self) -> &[u8; 20][src]

Returns the bytes making up the Sha1.

Panics if this is not a Sha1 hash, as identifiable by [Id::kind()].

Trait Implementations

impl AsRef<oid> for ObjectId[src]

impl Borrow<oid> for ObjectId[src]

impl Clone for ObjectId[src]

impl Copy for ObjectId[src]

impl Debug for ObjectId[src]

impl Deref for ObjectId[src]

type Target = oid

The resulting type after dereferencing.

impl<'de> Deserialize<'de> for ObjectId[src]

impl Display for ObjectId[src]

impl Eq for ObjectId[src]

impl From<&'_ oid> for ObjectId[src]

impl From<[u8; 20]> for ObjectId[src]

impl FromStr for ObjectId[src]

type Err = Error

The associated error which can be returned from parsing.

impl Hash for ObjectId[src]

impl Ord for ObjectId[src]

impl PartialEq<&'_ oid> for ObjectId[src]

impl PartialEq<ObjectId> for &oid[src]

impl PartialEq<ObjectId> for ObjectId[src]

impl PartialOrd<ObjectId> for ObjectId[src]

impl Serialize for ObjectId[src]

impl StructuralEq for ObjectId[src]

impl StructuralPartialEq for ObjectId[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.