From e92a1a6d2b006c3abeb693c7975cfe71c9a8698c Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Fri, 8 Nov 2024 22:41:07 -0500 Subject: [PATCH] Added id field. --- src/fields/mod.rs | 32 ++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 2 files changed, 33 insertions(+) create mode 100644 src/fields/mod.rs diff --git a/src/fields/mod.rs b/src/fields/mod.rs new file mode 100644 index 0000000..fa25bde --- /dev/null +++ b/src/fields/mod.rs @@ -0,0 +1,32 @@ +use std::fmt; +use uuid::Uuid; + +struct ID { + data: Uuid, +} + +impl ID { + fn new(id: Uuid) -> Self { + Self { + data: id, + } + } +} + +impl fmt::Display for ID { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.data) + } +} + +#[cfg(test)] +mod id { + use super::*; + + #[test] + fn id_new() { + let data = Uuid::new_v4(); + let id = ID::new(data.clone()); + assert_eq!(id.to_string(), data.to_string()); + } +} diff --git a/src/lib.rs b/src/lib.rs index 915b039..86d1293 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ mod client; +mod fields; mod message; mod router; mod session;