Skip to main content

cratefield_core/ports/
idgen.rs

1//! The `IdGen` port (architecture section 5): sortable ULID identifiers.
2
3use ulid::Ulid;
4
5pub trait IdGen: Send + Sync {
6    fn ulid(&self) -> String;
7}
8
9/// Real ULID generator (monotonic per process).
10#[derive(Debug, Clone, Copy, Default)]
11pub struct UlidIdGen;
12
13impl IdGen for UlidIdGen {
14    fn ulid(&self) -> String {
15        Ulid::generate().to_string()
16    }
17}