event_graph: add gen_id() function

This commit is contained in:
Dastan-glitch
2023-03-12 23:22:38 +03:00
parent 227dd68174
commit e118096815

View File

@@ -16,6 +16,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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