pub(crate) fn deterministic_uuid(seed: &str) -> String {
let h1 = fnv1a64(seed.as_bytes(), 0xcbf2_9ce4_8422_2325);
let h2 = fnv1a64(seed.as_bytes(), 0x8422_2325_cbf2_9ce4);
let mut b = [0u8; 16];
b[..8].copy_from_slice(&h1.to_be_bytes());
b[8..].copy_from_slice(&h2.to_be_bytes());
b[6] = (b[6] & 0x0f) | 0x50; b[8] = (b[8] & 0x3f) | 0x80; format!(
"{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}{:02x}{:02x}{:02x}{:02x}",
b[0],
b[1],
b[2],
b[3],
b[4],
b[5],
b[6],
b[7],
b[8],
b[9],
b[10],
b[11],
b[12],
b[13],
b[14],
b[15],
)
}
fn fnv1a64(data: &[u8], basis: u64) -> u64 {
let mut hash = basis;
for &byte in data {
hash ^= u64::from(byte);
hash = hash.wrapping_mul(0x0000_0100_0000_01b3);
}
hash
}