auths_core/ports/id.rs
1//! ID generation port.
2
3use uuid::Uuid;
4
5/// Port for UUID generation, enabling injection of deterministic implementations
6/// in tests and alternative ID schemes (ULIDs, Snowflake IDs) in production.
7pub trait UuidProvider: Send + Sync {
8 /// Generate a fresh unique identifier.
9 fn new_id(&self) -> Uuid;
10}
11
12/// Production adapter that delegates to `Uuid::new_v4()`.
13pub struct SystemUuidProvider;
14
15impl UuidProvider for SystemUuidProvider {
16 #[allow(clippy::disallowed_methods)]
17 fn new_id(&self) -> Uuid {
18 Uuid::new_v4()
19 }
20}