blob: 216b6825a93673980d39fc15420f4ffa296e57b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/*
This file is part of keks-meet (https://codeberg.org/metamuffin/keks-meet)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
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
}
}
|