re_types/datatypes/
uuid_ext.rs1use super::Uuid;
2
3impl From<Uuid> for uuid::Uuid {
4 #[inline]
5 fn from(uuid: Uuid) -> Self {
6 Self::from_bytes(uuid.bytes)
7 }
8}
9
10impl From<uuid::Uuid> for Uuid {
11 #[inline]
12 fn from(uuid: uuid::Uuid) -> Self {
13 Self {
14 bytes: *uuid.as_bytes(),
15 }
16 }
17}
18
19impl std::fmt::Display for Uuid {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 uuid::Uuid::from(*self).fmt(f)
22 }
23}
24
25#[cfg(test)]
26mod tests {
27 #[test]
28 fn test_uuid() {
29 let uuid = uuid::Uuid::new_v4();
30
31 let uuid_datatype: super::Uuid = uuid.into();
32
33 let uuid_roundtrip: uuid::Uuid = uuid_datatype.into();
34 assert_eq!(uuid, uuid_roundtrip);
35 }
36}