Struct rubedo::crypto::Sha256Hash
source · pub struct Sha256Hash { /* private fields */ }
Expand description
A SHA256 hash.
A formalised representation of a SHA256 hash, with support for common conversions, including serialisation and deserialisation using Serde.
The hash is stored internally as [u8; 32]
, which is the correct and most
efficient format, as emitted by Sha256::digest()
.
The conversion to and from a String
defaults to using hex strings rather
than base64-encoded strings, because this is more common, due to it being a
fixed-length string that is easy to read, verify, and transmit without any
compatibility issues. However, base64 conversion functions are also provided
for convenience in case that format is preferred.
Implementations§
source§impl Sha256Hash
impl Sha256Hash
Trait Implementations§
source§impl ByteSized<32> for Sha256Hash
impl ByteSized<32> for Sha256Hash
source§fn to_bytes(&self) -> [u8; 32]
fn to_bytes(&self) -> [u8; 32]
source§fn from_bytes(bytes: [u8; 32]) -> Self
fn from_bytes(bytes: [u8; 32]) -> Self
source§fn from_base64(encoded: &str) -> Result<Self, DecodeError>
fn from_base64(encoded: &str) -> Result<Self, DecodeError>
source§impl ByteSizedMut<32> for Sha256Hash
impl ByteSizedMut<32> for Sha256Hash
source§impl Clone for Sha256Hash
impl Clone for Sha256Hash
source§fn clone(&self) -> Sha256Hash
fn clone(&self) -> Sha256Hash
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Sha256Hash
impl Debug for Sha256Hash
source§impl Default for Sha256Hash
impl Default for Sha256Hash
source§fn default() -> Sha256Hash
fn default() -> Sha256Hash
source§impl<'de> Deserialize<'de> for Sha256Hash
impl<'de> Deserialize<'de> for Sha256Hash
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl Display for Sha256Hash
impl Display for Sha256Hash
source§impl ForceFrom<&[u8]> for Sha256Hash
impl ForceFrom<&[u8]> for Sha256Hash
source§fn force_from(b: &[u8]) -> Self
fn force_from(b: &[u8]) -> Self
Converts a &[u8]
to a [$t
].
Note that if the incoming [u8]
is too long to fit, it will be
truncated without error or warning. If there is not enough data, it will
be padded with zeroes. If this situation needs checking, use
try_from()
instead.
source§impl From<&GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>> for Sha256Hash
impl From<&GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>> for Sha256Hash
source§fn from(a: &GenericArray<u8, U32>) -> Self
fn from(a: &GenericArray<u8, U32>) -> Self
Converts a GenericArray<u8, $o>
to a [$t
].
source§impl From<GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>> for Sha256Hash
impl From<GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>> for Sha256Hash
source§fn from(a: GenericArray<u8, U32>) -> Self
fn from(a: GenericArray<u8, U32>) -> Self
Converts a GenericArray<u8, $o>
to a [$t
].
source§impl FromStr for Sha256Hash
impl FromStr for Sha256Hash
source§impl Hash for Sha256Hash
impl Hash for Sha256Hash
source§impl Hashed for Sha256Hash
impl Hashed for Sha256Hash
§type Algorithm = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>
type Algorithm = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>
§type OutputSize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>
type OutputSize = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>
source§fn from_digest(output: GenericArray<u8, Self::OutputSize>) -> Self
fn from_digest(output: GenericArray<u8, Self::OutputSize>) -> Self
source§impl PartialEq<&[u8; 32]> for Sha256Hash
impl PartialEq<&[u8; 32]> for Sha256Hash
source§impl PartialEq<[u8; 32]> for Sha256Hash
impl PartialEq<[u8; 32]> for Sha256Hash
source§impl PartialEq for Sha256Hash
impl PartialEq for Sha256Hash
source§fn eq(&self, other: &Sha256Hash) -> bool
fn eq(&self, other: &Sha256Hash) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for Sha256Hash
impl Serialize for Sha256Hash
source§impl TryFrom<&[u8]> for Sha256Hash
impl TryFrom<&[u8]> for Sha256Hash
source§impl TryFrom<&String> for Sha256Hash
impl TryFrom<&String> for Sha256Hash
source§impl TryFrom<&str> for Sha256Hash
impl TryFrom<&str> for Sha256Hash
source§impl TryFrom<String> for Sha256Hash
impl TryFrom<String> for Sha256Hash
impl Copy for Sha256Hash
impl Eq for Sha256Hash
impl StructuralPartialEq for Sha256Hash
Auto Trait Implementations§
impl Freeze for Sha256Hash
impl RefUnwindSafe for Sha256Hash
impl Send for Sha256Hash
impl Sync for Sha256Hash
impl Unpin for Sha256Hash
impl UnwindSafe for Sha256Hash
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.