active-uuid-registry
A functional interface for managing sets of UUIDs organized by named contexts in a global registry. Useful for tracking running components in dynamic and complex systems.
Installation
Add to your Cargo.toml:
[]
= "0.4.1"
By default, the registry uses a mutex-protected hashmap of arc and hashsets.
For concurrent access with DashMap/DashSet, enable the concurrent-map feature:
[]
= { = "0.4.1", = ["concurrent-map"] }
Usage
use ;
use UuidPoolError;
use Uuid;
// Reserve a new UUID in a named context
let reserve_res: = reserve;
// Add an existing UUID to a context
let custom_uuid = ...; // create your UUID here
let add_res: = add;
let add_res: = add;
// Remove a UUID from a context
let remove_res: = remove;
// Try to remove the UUID from the `client` context
let removed: bool = try_remove;
// Replace one UUID with another within the same context
let old = reserve.unwrap;
let new = ...; // create your UUID here
let replace_res: = replace;
// Get all UUIDs for any given context
let ids: = get;
// Get all UUIDs currently stored
let all_ids: = get_all;
// Clear all UUIDs from a certain context
let clear_res: = clear_context;
// Clear all UUIDs from all contexts
let clear_res: = clear_all_contexts;
// Clears and returns all UUIDs from a certain context
let drain_res: = drain_context;
// Clears and returns all UUIDs from all contexts
let drain_res: = drain_all_contexts;
API
| Function | Description |
|---|---|
reserve(context) |
Generate and register a new UUID in the given context |
reserve_with_base(context, base) |
Reserve with custom base parameter |
reserve_with(context, base, max_retries) |
Reserve with custom base and retry count |
add(context, uuid) |
Register an existing UUID in a context |
remove(context, uuid) |
Remove a UUID from a context (returns Result) |
try_remove(context, uuid) |
Remove a UUID from a context (returns bool) |
replace(context, old, new) |
Replace one UUID with another in a context |
get(context) |
Get all UUIDs stored for a specific context |
get_all() |
Get all UUIDs stored |
clear_context(context) |
Remove all UUIDS from a specific context |
clear_all_contexts() |
Remove all UUIDs from all contexts |
drain_context(context) |
Removes and returns all UUIDs from a specific context |
drain_all_contexts() |
Removes and returns all UUIDs from all contexts |