cratefield-core 0.3.0

Factory Zero harness kernel: Module trait, Harness builder, ports, errors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The `IdGen` port (architecture section 5): sortable ULID identifiers.

use ulid::Ulid;

pub trait IdGen: Send + Sync {
    fn ulid(&self) -> String;
}

/// Real ULID generator (monotonic per process).
#[derive(Debug, Clone, Copy, Default)]
pub struct UlidIdGen;

impl IdGen for UlidIdGen {
    fn ulid(&self) -> String {
        Ulid::generate().to_string()
    }
}