pub struct HandlerId(/* private fields */);Expand description
Opaque identifier for a registered handler.
Returned by SyncRegistry::register and
its priority/guard variants, accepted by
SyncRegistry::unregister.
HandlerId is Copy and cheap to compare. The internal numeric
representation is intentionally opaque: callers should not rely on
specific values or any ordering between ids.
§Uniqueness
Ids are unique within the registry that issued them, for the lifetime of that registry. Two registries may issue the same numeric id; never use an id with a registry other than the one that returned it.
§Examples
use registry_io::SyncRegistry;
let registry: SyncRegistry<u32> = SyncRegistry::new();
let id_a = registry.register(|_| {});
let id_b = registry.register(|_| {});
assert_ne!(id_a, id_b);
assert!(registry.unregister(id_a));
assert!(registry.unregister(id_b));Implementations§
Source§impl HandlerId
impl HandlerId
Sourcepub const fn as_u64(self) -> u64
pub const fn as_u64(self) -> u64
Returns the raw numeric value backing this id.
The exact numeric domain is unspecified and may change between releases. This is provided for diagnostic use only (logging, debugging); do not rely on specific values or arithmetic over them.
§Examples
use registry_io::SyncRegistry;
let registry: SyncRegistry<()> = SyncRegistry::new();
let id = registry.register(|_| {});
let raw = id.as_u64();
assert!(raw > 0);