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. Also includes error construction macros with automatic source location capture.
§Derive Macros
#[derive(HexDomain)]- Mark domain layer types#[derive(HexPort)]- Mark port traits#[derive(HexAdapter)]- Mark adapter implementations#[derive(HexEntity)]- Implement HexEntity trait#[derive(HexValueItem)]- Implement HexValueItem trait with default validation#[derive(HexAggregate)]- Mark aggregate roots#[derive(Repository)]- Mark repository ports
§Error Macros
hex_domain_error!(code, message)- Create domain error with source locationhex_port_error!(code, message)- Create port error with source locationhex_adapter_error!(code, message)- Create adapter error with source location
§Example
ⓘ
use hexser::prelude::*;
#[derive(HexDomain, HexEntity)]
struct User {
id: String,
email: String,
}
let err = hex_domain_error!("E_HEX_001", "Invalid state");Revision History
- 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.