mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
refactor: use UUID for envelope id to prevent accidental deletion
This commit is contained in:
@@ -107,7 +107,7 @@ macro_rules! raise_error {
|
||||
$crate::modules::error::BichonError::Generic {
|
||||
message: $msg,
|
||||
code: $code,
|
||||
location: snafu::location!()
|
||||
location: snafu::location!(),
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -243,13 +243,6 @@ pub fn validate_email(email: &str) -> crate::modules::error::BichonResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! calculate_hash {
|
||||
($name:expr) => {
|
||||
$crate::modules::utils::hash($name)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! id {
|
||||
($bit_strength:expr) => {{
|
||||
@@ -277,6 +270,14 @@ pub fn hash(s: &str) -> u64 {
|
||||
(hash & 0x1F_FFFF_FFFF_FFFF) as u64
|
||||
}
|
||||
|
||||
pub fn hex_hash(s: &str) -> String {
|
||||
let mut cursor = Vec::new();
|
||||
cursor.extend_from_slice(s.as_bytes());
|
||||
let mut cursor = std::io::Cursor::new(cursor);
|
||||
let hash = murmur3::murmur3_x64_128(&mut cursor, 0).unwrap();
|
||||
format!("{:032x}", hash)
|
||||
}
|
||||
|
||||
pub fn create_hash(account_id: u64, field: &str) -> u64 {
|
||||
let mut buffer = Vec::new();
|
||||
buffer.extend_from_slice(&account_id.to_le_bytes());
|
||||
@@ -370,3 +371,8 @@ pub fn validate_tag(tag: &str) -> Result<(), String> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn content_hash(content: &[u8]) -> String {
|
||||
let hash = blake3::hash(content);
|
||||
hash.to_hex().to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user