use alloc::string::String;
use iceoryx2_bb_container::semantic_string::{SemanticString, SemanticStringError};
use iceoryx2_bb_system_types::base64url::Base64Url;
pub mod recommended;
pub mod sha1;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct HashValue {
value: Base64Url,
}
impl HashValue {
pub(crate) fn new(bytes: &[u8]) -> Result<HashValue, SemanticStringError> {
Ok(Self {
value: Base64Url::new(bytes)?,
})
}
pub fn as_base64url(&self) -> &Base64Url {
&self.value
}
}
impl From<HashValue> for String {
fn from(value: HashValue) -> Self {
value.as_base64url().into()
}
}
impl From<&HashValue> for String {
fn from(value: &HashValue) -> Self {
value.as_base64url().into()
}
}
pub trait Hash {
fn new(bytes: &[u8]) -> Self;
fn value(&self) -> HashValue;
}