Quark
Generic link-time registry infrastructure for Rust.
Quark provides a Registrable trait, an owned Registry<T>, and a define_registry!
macro for building type-safe registries backed by inventory
link-time collection.
Status: v0.1.1 early release · MIT · GitHub
Performance (see study): lookups ~15 ns at 10k entries; compile scales ~linearly with inventory::submit! count.
Mental model
- Type-safe registries with minimal boilerplate
- Link-time collection via
inventory::submit!(per consumer crate) - Owned registry instances (no global
Mutex) quark::inventoryre-export keepsinventoryversions in sync across consumers
Quick start
Define a descriptor and make it registrable:
use Registrable;
collect!;
Define a typed registry:
define_registry!
Discover at startup:
let registry = auto_discover;
let script = registry.get.unwrap;
Example use cases
| Use case | Example registry | What you register |
|---|---|---|
| Script / job scheduling | ScriptRegistry, JobRegistry |
Named scripts and default job handlers |
| Task / workflow engine | TaskRegistry |
Task types and their handlers |
| Messaging / routing | TopicRegistry, RouteRegistry |
Topics and WebSocket or HTTP route descriptors |
| Schema / type system | SchemaRegistry, TraitRegistry |
Schemas and trait implementations |
| Plugin / app discovery | AppRegistry, SearchSourceRegistry |
Installable apps and search index sources |
Downstream crates should depend on quark and import quark::inventory (the re-export)
rather than adding a separate inventory dependency.
Examples
Runnable walkthroughs, from single-file basics to a two-crate plugin host proving cross-crate
link-time discovery: examples/README.md.
Compile-scale fixtures
When you need to measure how inventory compile cost scales with registry size — before adopting Quark in a macro-heavy crate — use the generated packages under benches/compile-scale/. Each quark-scale-{N}/ crate contains N inventory::submit! entries (tiers: 1, 10, 100, 500, 1000, 5000, 10000).
Regenerate tiers:
Cold build sweep:
Incremental scenarios:
These are manual / scheduled benchmarks — not part of default CI. See benches/compile-scale/README.md and docs/PERFORMANCE_STUDY.md for methodology.
Development
Documentation
| Doc | Audience |
|---|---|
cargo doc --open |
API reference |
examples/README.md |
Runnable walkthrough ladder |
docs/PERFORMANCE_STUDY.md |
Benchmark summary and adoption guidance |
docs/profiling.md |
Reproducing benchmarks |
CONTRIBUTING.md |
Development and PRs |
SECURITY.md |
Vulnerability reporting |
CODE_OF_CONDUCT.md |
Community standards |
License
MIT (see LICENSE).