Crate hexser_macros

Crate hexser_macros 

Source
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(Entity)] - Implement Entity trait
  • #[derive(Repository)] - Mark repository ports

§Error Macros

  • hex_domain_error!(code, message) - Create domain error with source location
  • hex_port_error!(code, message) - Create port error with source location
  • hex_adapter_error!(code, message) - Create adapter error with source location

§Example

use hexser::prelude::*;

#[derive(HexDomain, Entity)]
struct User {
    id: String,
    email: String,
}

let err = hex_domain_error!("E_HEX_001", "Invalid state");

Revision History

  • 2025-10-06T02:00:00Z @AI: Add error construction macros.
  • 2025-10-02T00:00:00Z @AI: Initial Phase 3 proc macro crate.

Macros§

hex_adapter_error
hex_domain_error
hex_port_error

Derive Macros§

Entity
HexAdapter
HexAggregate
HexDirective
HexDomain
HexPort
HexQuery
HexRepository