From e118096815e9991c8ad316f42e18ac246d73ca46 Mon Sep 17 00:00:00 2001 From: Dastan-glitch Date: Sun, 12 Mar 2023 23:22:38 +0300 Subject: [PATCH] event_graph: add gen_id() function --- src/event_graph/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/event_graph/mod.rs b/src/event_graph/mod.rs index 43b9ecff9..ec6ff62f5 100644 --- a/src/event_graph/mod.rs +++ b/src/event_graph/mod.rs @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +use rand::{distributions::Alphanumeric, thread_rng, Rng}; + pub mod events_queue; pub mod model; pub mod protocol_event; @@ -25,6 +27,10 @@ pub trait EventMsg { fn new() -> Self; } +pub fn gen_id(len: usize) -> String { + thread_rng().sample_iter(&Alphanumeric).take(len).map(char::from).collect() +} + pub fn get_current_time() -> u64 { let start = std::time::SystemTime::now(); start