[−][src]Struct git_hash::owned::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]
array_methods)Returns a slice containing the entire array. Equivalent to &s[..].
pub fn each_ref(&self) -> [&T; N][src]
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.
pub fn deref(&self) -> &Self::Target[src]
impl<'de> Deserialize<'de> for Digest[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
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]
pub fn hash<__H: Hasher>(&self, state: &mut __H)[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl Ord for Digest[src]
pub fn cmp(&self, other: &Digest) -> Ordering[src]
#[must_use]pub fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self1.50.0[src]
impl PartialEq<Digest> for Digest[src]
impl PartialOrd<Digest> for Digest[src]
pub fn partial_cmp(&self, other: &Digest) -> Option<Ordering>[src]
pub fn lt(&self, other: &Digest) -> bool[src]
pub fn le(&self, other: &Digest) -> bool[src]
pub fn gt(&self, other: &Digest) -> bool[src]
pub fn ge(&self, other: &Digest) -> bool[src]
impl Serialize for Digest[src]
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer, [src]
__S: Serializer,
impl StructuralEq for Digest[src]
impl StructuralPartialEq for Digest[src]
Auto Trait Implementations
impl RefUnwindSafe for Digest[src]
impl Send for Digest[src]
impl Sync for Digest[src]
impl Unpin for Digest[src]
impl UnwindSafe for Digest[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,