aboutsummaryrefslogtreecommitdiff
path: root/utils/src/idgen.rs
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-03-27 22:47:57 +0100
committerTom Smeding <tom.smeding@gmail.com>2020-03-27 22:47:57 +0100
commitfd421e32780cad46782c16cd4e15947f295a08c7 (patch)
tree04632f49f7c8860dee4237a0afe8292a949bdc9e /utils/src/idgen.rs
Initial, untested version of controller and worker
Worker has been tested to a marginal extent, but the controller is litereally untested.
Diffstat (limited to 'utils/src/idgen.rs')
-rw-r--r--utils/src/idgen.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/utils/src/idgen.rs b/utils/src/idgen.rs
new file mode 100644
index 0000000..20f13ff
--- /dev/null
+++ b/utils/src/idgen.rs
@@ -0,0 +1,16 @@
+#[derive(Debug)]
+pub struct IdGen {
+ next: u64,
+}
+
+impl IdGen {
+ pub fn new(start: u64) -> Self {
+ IdGen { next: start }
+ }
+
+ pub fn gen(&mut self) -> u64 {
+ let res = self.next;
+ self.next += 1;
+ res
+ }
+}