Skip to main content

active_uuid_registry/
lib.rs

1//! # Active UUID Registry
2//! 
3//! A library for managing in-process, system-wide `UUID`s for tracking component liveness.
4//! 
5//! This library provides a thread-safe UUID pool that can be used to track the liveness of UUIDs.
6//! 
7//! UUIDs are organized in a two-level global registry (`namespace -> context -> UUID set`), making it straightforward to track running components across logical scopes in dynamic systems.
8//! 
9//! Strongly encouraged to use proper management and implementation practices for their particular process/use-case, as there is no garbage collection or pool monitoring on the part of this library.
10//! 
11//! Use at your own (possible but unlikely) risk. *You* are responsible for managing the pool and its contents.
12//! 
13//! # Feature Flags
14//! 
15//! - **Default / single-threaded**: Use a single-threaded map for the UUID pool.
16//!   - Uses a `parking_lot::Mutex<HashMap<NamespaceKey, HashMap<ContextKey, HashSet<Uuid>>>>` for the UUID pool.
17//! - **concurrent-map**: Use a concurrent map for the UUID pool.
18//!   - Uses a `DashMap<NamespaceKey, DashMap<ContextKey, DashSet<Uuid>>>` for the UUID pool.
19//! 
20
21
22mod registry;
23
24/// Interface API module for the Active UUID Registry.
25pub mod interface;
26
27#[doc(inline)]
28pub use uuid as registry_uuid;  
29
30/// Represents the name of a namespace within the registry pool.
31pub type NamespaceString = String;
32
33/// Represents the name of a context within the registry pool.
34pub type ContextString = String;
35
36/// Error type for UUID pool operations.
37#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq, Hash)]
38pub enum UuidPoolError {
39    #[error("Failed to generate unique UUID: {0}")]
40    FailedToGenerateUniqueUuidError(String),
41    #[error("Failed to find UUID in pool: {0}")]
42    FailedToFindUuidInPoolError(String),
43    #[error("Failed to set UUID in pool: {0}")]
44    FailedToSetUuidInPoolError(String),
45    #[error("Failed to add UUID to pool: {0}")]
46    FailedToAddUuidToPoolError(String),
47    #[error("Failed to remove UUID from pool: {0}")]
48    FailedToRemoveUuidFromPoolError(String),
49    #[error("Failed to replace UUID in pool: {0}")]
50    FailedToReplaceUuidInPoolError(String),
51}