pub enum HashAlgo {
Md5,
Sha1,
Sha256,
Sha512,
}Expand description
This are the hash algorithms supported by cppnix.
Variants§
Implementations§
Source§impl HashAlgo
impl HashAlgo
pub const fn as_str(&self) -> &'static str
pub const fn sri_prefix(&self) -> &'static str
pub const fn digest_length(&self) -> usize
Source§impl HashAlgo
impl HashAlgo
Sourcepub fn digest_bytes<C: AsRef<[u8]>>(&self, content: C) -> NixHash
pub fn digest_bytes<C: AsRef<[u8]>>(&self, content: C) -> NixHash
Shorthand for digesting a byte slice.
§Examples
use nix_compat::nixhash::HashAlgo;
let sha256 = HashAlgo::Sha256.digest_bytes("abc");
assert_eq!(sha256.to_nix_nixbase32(), "sha256:1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s");Sourcepub fn digest_display<D: Display>(&self, value: D) -> NixHash
pub fn digest_display<D: Display>(&self, value: D) -> NixHash
Hashes an agument implementing display with this algorithm, without an intermediate buffer.
Analogous to std::fmt::format.
§Examples
use nix_compat::nixhash::HashAlgo;
let sha256 = HashAlgo::Sha256.digest_display(format_args!("{}bc", "a"));
assert_eq!(sha256.to_nix_nixbase32(), "sha256:1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s");Trait Implementations§
Source§impl<'de> Deserialize<'de> for HashAlgo
impl<'de> Deserialize<'de> for HashAlgo
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl NixDeserialize for HashAlgo
Available on crate features wire and nix-compat-derive only.
impl NixDeserialize for HashAlgo
Available on crate features
wire and nix-compat-derive only.Source§fn try_deserialize<R>(
reader: &mut R,
) -> impl Future<Output = Result<Option<Self>, R::Error>> + Send + '_
fn try_deserialize<R>( reader: &mut R, ) -> impl Future<Output = Result<Option<Self>, R::Error>> + Send + '_
Read a value from the reader.
This returns an Option to support gracefull shutdown.
fn deserialize<R>( reader: &mut R, ) -> impl Future<Output = Result<Self, R::Error>> + Send + '_
Source§impl NixSerialize for HashAlgo
Available on crate features wire and nix-compat-derive only.
impl NixSerialize for HashAlgo
Available on crate features
wire and nix-compat-derive only.impl Copy for HashAlgo
impl Eq for HashAlgo
impl StructuralPartialEq for HashAlgo
Auto Trait Implementations§
impl Freeze for HashAlgo
impl RefUnwindSafe for HashAlgo
impl Send for HashAlgo
impl Sync for HashAlgo
impl Unpin for HashAlgo
impl UnsafeUnpin for HashAlgo
impl UnwindSafe for HashAlgo
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.