[][src]Struct ssb_crypto::Hash

#[repr(C)]pub struct Hash(pub [u8; 32]);

A sha256 hash digest. The standard hash in the scuttleverse.

Implementations

impl Hash[src]

pub const SIZE: usize[src]

The size in bytes of the Hash type ( == 32).

pub fn from_slice(s: &[u8]) -> Option<Self>[src]

Deserialize from byte representation. Returns None if the slice length isn't 32. Note that this doesn't hash the provided byte slice, use the hash function for that.

pub fn from_base64(s: &str) -> Option<Self>[src]

Deserialize from base-64 string representation. Ignores optional leading '%' or '&' sigil and '.sha256' suffix.

Example

let s = "%4hUgS4j0TwKdsZzOV/tfqiPtqoLw2qYg/Wl9Xy8FPEU=.sha256";
let h = ssb_crypto::Hash::from_base64(s).unwrap();

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

Does not include ".sha256" suffix or a sigil prefix.

Example

let s = "4hUgS4j0TwKdsZzOV/tfqiPtqoLw2qYg/Wl9Xy8FPEU=";
let h = ssb_crypto::Hash::from_base64(s).unwrap();
assert_eq!(h.as_base64(), s);

Trait Implementations

impl AsBytes for Hash[src]

impl Debug for Hash[src]

impl FromBytes for Hash[src]

impl PartialEq<Hash> for Hash[src]

impl StructuralPartialEq for Hash[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> From<T> for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,