platform_core/ids.rs
1use std::fmt::Debug;
2use std::sync::Arc;
3use uuid::Uuid;
4
5pub trait IdGenerator: Debug + Send + Sync {
6 fn new_id(&self, prefix: &str) -> String;
7}
8
9pub type DynIdGenerator = Arc<dyn IdGenerator>;
10
11#[derive(Debug, Default)]
12pub struct UuidGenerator;
13
14impl IdGenerator for UuidGenerator {
15 fn new_id(&self, prefix: &str) -> String {
16 format!("{prefix}_{}", Uuid::now_v7())
17 }
18}