use uuid::Uuid;
pub struct PublicId;
impl PublicId {
pub fn mask_uuid(prefix: &str, id: Uuid) -> String {
let hex = id.simple().to_string();
format!("{}_{}", prefix, hex)
}
pub fn unmask_uuid(prefix: &str, public_id: &str) -> Option<Uuid> {
let expected_prefix = format!("{}_", prefix);
if public_id.starts_with(&expected_prefix) {
let hex = &public_id[expected_prefix.len()..];
Uuid::parse_str(hex).ok()
} else {
None
}
}
}