Expand description
Procedural macros for the hex crate.
This crate provides derive macros that enable zero-boilerplate hexagonal architecture by automatically implementing registration traits and generating metadata for compile-time graph construction.
§Derive Macros
#[derive(HexDomain)]- Register a domain-layer type (role defaults toEntity)#[derive(HexPort)]- Register a port-layer type (role defaults toRepository; override with#[hex(role = "InputPort")])#[derive(HexAdapter)]- Register an adapter and mark it as anAdapter#[derive(HexEntity)]- ImplementHexEntity, takingIdfrom theidfield#[derive(HexValueItem)]- ImplementHexValueItemwith default validation#[derive(HexAggregate)]- ImplementAggregatewith default invariant check#[derive(HexDirective)]- ImplementDirectiveand register (roleDirective)#[derive(HexQuery)]- Register a query type (roleQuery)#[derive(HexRepository)]- Semantic marker for repository ports (pair withHexPort)
§Example
ⓘ
use hexser::prelude::*;
#[derive(HexDomain, HexEntity)]
struct User {
id: String,
email: String,
}Revision History
- 2026-07-20T00:00:00Z @AI: Remove unexported/unused/non-functional error macros and their dead codegen; refresh docs to match the shipped derive set.
- 2025-10-09T14:14:00Z @AI: Remove Entity derive, expose only HexEntity for clarity.
- 2025-10-06T02:00:00Z @AI: Add error construction macros.
- 2025-10-02T00:00:00Z @AI: Initial Phase 3 proc macro crate.