aboutsummaryrefslogtreecommitdiff
path: root/server/src/idgen.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/idgen.rs')
-rw-r--r--server/src/idgen.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/server/src/idgen.rs b/server/src/idgen.rs
new file mode 100644
index 0000000..0cdc983
--- /dev/null
+++ b/server/src/idgen.rs
@@ -0,0 +1,21 @@
+use tokio::sync::RwLock;
+
+pub struct IdGenerator {
+ x: RwLock<u64>,
+}
+
+impl Default for IdGenerator {
+ fn default() -> Self {
+ Self {
+ x: Default::default(),
+ }
+ }
+}
+impl IdGenerator {
+ pub async fn generate(&self) -> u64 {
+ // TODO: dummy implementation; ideal would be encrypting the counter
+ let mut x = self.x.write().await;
+ *x += 1;
+ *x
+ }
+}