[][src]Struct git_hash::owned::Digest

pub struct Digest(_);

An owned hash identifying objects, most commonly Sha1

Implementations

impl Digest[src]

Access and conversion

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

Returns the kind of hash used in this Digest

pub fn to_borrowed(&self) -> Digest<'_>[src]

Return a borrowed version of this instance

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, mut out: impl Write) -> Result<()>[src]

Write ourselves to out in hexadecimal notation

impl Digest[src]

Sha1 hash specific methods

pub fn from_40_bytes_in_hex(buffer: &[u8]) -> Result<Digest, 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)

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]) -> Digest[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]) -> Digest[src]

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

pub fn null_sha1() -> Digest[src]

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

Methods from Deref<Target = [u8; 20]>

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

🔬 This is a nightly-only experimental API. (array_methods)

Returns a slice containing the entire array. Equivalent to &s[..].

pub fn each_ref(&self) -> [&T; N][src]

🔬 This is a nightly-only experimental API. (array_methods)

Borrows each element and returns an array of references with the same size as self.

Example

#![feature(array_methods)]

let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);

This method is particularly useful if combined with other methods, like map. This way, you can can avoid moving the original array if its elements are not Copy.

#![feature(array_methods, array_map)]

let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);

// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);

Trait Implementations

impl Clone for Digest[src]

impl Copy for Digest[src]

impl Debug for Digest[src]

impl Deref for Digest[src]

type Target = [u8; 20]

The resulting type after dereferencing.

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

impl Display for Digest[src]

impl Eq for Digest[src]

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

impl<'a> From<Digest<'a>> for Digest[src]

impl Hash for Digest[src]

impl Ord for Digest[src]

impl PartialEq<Digest> for Digest[src]

impl PartialOrd<Digest> for Digest[src]

impl Serialize for Digest[src]

impl StructuralEq for Digest[src]

impl StructuralPartialEq for Digest[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.