Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions helix-db/src/utils/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ impl ID {
self.0
}

pub fn id(&self) -> u128 {
self.0
}

pub fn stringify(&self) -> String {
uuid::Uuid::from_u128(self.0).to_string()
}
Expand Down Expand Up @@ -117,14 +121,12 @@ pub fn v6_uuid() -> u128 {
uuid::Uuid::now_v6(&[1, 2, 3, 4, 5, 6]).as_u128()
}


#[cfg(test)]
mod tests {
use sonic_rs::json;

use super::*;


#[test]
fn test_uuid_deserialization() {
let uuid = json!({ "id": "1f07ae4b-e354-6660-b5f0-fd3ce8bc4b49" });
Expand All @@ -134,9 +136,11 @@ mod tests {
id: ID,
}


let deserialized: IDWrapper = sonic_rs::from_value(&uuid).unwrap();
assert_eq!(deserialized.id.stringify(), "1f07ae4b-e354-6660-b5f0-fd3ce8bc4b49");
assert_eq!(
deserialized.id.stringify(),
"1f07ae4b-e354-6660-b5f0-fd3ce8bc4b49"
);
}

#[test]
Expand All @@ -151,4 +155,4 @@ mod tests {

assert_eq!(uuid.to_string(), "1f07ae4b-e354-6660-b5f0-fd3ce8bc4b49");
}
}
}
Loading