Expand description
§registry-io
High-performance event and callback registry primitive for Rust.
registry-io provides a focused alternative to channel-based notification
when several components need to react to the same in-process event with
the lowest possible dispatch overhead. The hot path is lock-free,
allocation-free, and panic-isolating.
§Design philosophy
- Sync-first. The default registry runs handlers inline on the calling thread, with sub-microsecond dispatch overhead.
- Lock-free reads. Multiple threads can fire
SyncRegistry::notifyconcurrently without serialization. - Zero allocation on the hot path.
notifywalks anarc_swap::ArcSwapsnapshot ofArc<dyn Fn>pointers and dispatches each one — no allocations along the no-panic path. - Panic isolation. A panic in one handler is caught and does not stop sibling handlers or propagate to the caller.
- Priority ordering. Handlers may be registered with a priority value; higher priorities fire first, ties broken in registration order.
- RAII unregistration.
HandlerGuardcleans up automatically.
§Quick start
use std::sync::Arc;
use std::sync::atomic::{AtomicU32, Ordering};
use registry_io::SyncRegistry;
let registry: SyncRegistry<u32> = SyncRegistry::new();
let counter = Arc::new(AtomicU32::new(0));
let sink = Arc::clone(&counter);
let id = registry.register(move |value| {
sink.fetch_add(*value, Ordering::Relaxed);
});
registry.notify(&5);
registry.notify(&7);
assert_eq!(counter.load(Ordering::Relaxed), 12);
assert!(registry.unregister(id));§Feature flags
std(default) — enables the standard library. Required for sync and async registries.sync(default) — exposesSyncRegistry. Impliesstd.async— reserved for a future release; exposesAsyncRegistryforasync fnhandlers. Impliesstd.hybrid— activates bothsyncandasync.
§Out of scope
registry-io is a local, in-process primitive. It is not a pub/sub
broker, not a message bus, and not a replacement for channels
when you need cross-process or cross-network delivery with backpressure.
See the project README for a list of when not to use it.
§License
Dual-licensed under Apache-2.0 OR MIT.
Re-exports§
pub use sync::HandlerGuard;syncpub use sync::SyncRegistry;syncpub use async::AsyncHandlerGuard;asyncpub use async::AsyncRegistry;async
Modules§
Structs§
- Handler
Id - Opaque identifier for a registered handler.
- Panic
Info syncorasync - Information about a panic that occurred inside a handler.
Constants§
- VERSION
- Crate version string, populated by Cargo at build time.