klauthed-macros 0.1.0

Procedural macros for klauthed, including #[derive(DomainError)].
Documentation

klauthed-macros

Procedural macros for klauthed (a leaf crate).

Currently provides #[derive(DomainError)], which generates the klauthed_error::DomainError impl from #[domain(...)] attributes so error enums don't hand-write the category() / code() match arms:

#[derive(Debug, DomainError)]
#[domain(prefix = "security", category = "internal")]
enum SecurityError {
    #[domain(category = "unauthorized", code = "expired_token")]
    ExpiredToken,
    // default category = "internal", default code = snake_case(variant)
    Rng,
}

Codes are emitted as "<prefix>.<reason>"; the derive correctly snake-cases acronyms (HTTPErrorhttp_error) and forwards #[cfg] on variants.


Part of the klauthed rust-libraries workspace. Browse the API: cargo doc -p klauthed-macros --open.

License

Dual-licensed under MIT or Apache-2.0, at your option.