hexser_macros — Procedural macros for the hexser crate
A small companion utility crate for the main hexser library.
This crate provides the procedural macros that power hexser’s zero‑boilerplate Hexagonal Architecture experience (Ports & Adapters). Most users should depend on hexser directly and let it enable/use these macros. Depend on hexser_macros directly only if you have an advanced use case and know you specifically need the raw macros.
Relationship to hexser (recommended usage)
In typical projects you do not need to add hexser_macros explicitly. The main crate re‑exports and uses these macros for you.
[]
= "0.4.7" # macros enabled by default via the `macros` feature
Advanced users who know they only need the macros can depend directly, but this is uncommon:
[]
= "0.4.7"
Note: The derive and attribute macros are designed to work with the types/traits defined in
hexser. Using them standalone usually requireshexserin your dependency tree anyway.
Version compatibility
- Keep
hexser_macrosandhexseron the same minor/patch version (e.g.,0.3.x). - When upgrading
hexser, upgradehexser_macrosto the matching version.
Links
- Main crate (recommended): https://crates.io/crates/hexser
- Docs: https://docs.rs/hexser_macros
- Repository: https://github.com/squillo/hexser
- Publishing guide: ./../../PUBLISHING.md
License
Licensed under either of
- Apache License, Version 2.0, or
- MIT license
at your option.
Derive macros
All are re-exported from hexser (and its prelude) under the macros feature, so use
hexser::HexDomain etc. rather than depending on this crate directly.
| Derive | Effect | Registered role |
|---|---|---|
HexDomain |
Registrable + graph registration |
Entity (override: #[hex(role = "…")]) |
HexPort |
Registrable + graph registration |
Repository (override: #[hex(role = "InputPort")]) |
HexAdapter |
Registrable + Adapter marker + registration |
Adapter (override via #[hex(role)]) |
HexDirective |
Directive impl + registration |
Directive |
HexQuery |
Registrable + registration |
Query |
HexEntity |
HexEntity impl (Id from the id field) |
— |
HexValueItem |
HexValueItem impl (default validation) |
— |
HexAggregate |
Aggregate impl (default invariant check) |
— |
HexRepository |
Semantic marker (pair with HexPort) |
— |
Notes:
- Derives apply to structs/enums, not traits.
- Generic types compile (the
Registrableimpl is generated with aSelf: 'staticbound), but they are not auto-registered in the inventory graph — register a concrete alias instead. HexEntityon a struct without anidfield is a compile error (choose theIdexplicitly).
Knowledge Graph (high level)
- hexser_macros
- modules:
derive— the nine derive implementations abovecommon::codegen— sharedRegistrable+inventory::submit!code generation and#[hex(role = "…")]parsingcommon::validation— target validation (struct/enum only)
- provides: derive macros used by
hexser - consumed by:
hexser(compile time) - typical user dependency:
hexser(not this crate directly) - tests:
hexser/tests/derive_registration_test.rs(runtime graph registration),hexser/tests/macro_tests.rs(derive usage),hexser/tests/trybuild_ui.rs(compile-fail)
- modules: