component!() { /* proc-macro */ }Expand description
Define component enums with automatic ComponentId trait implementation.
§WDP Naming Convention
Per WDP specification, component names SHOULD use PascalCase:
- ✅
Auth,Database,ApiGateway,TokenValidator - ❌
AUTH,DATABASE,API_GATEWAY(non-standard)
Error codes follow the format: E.Component.Primary.SEQUENCE
- Example:
E.Auth.Token.EXPIREDnotE.AUTH.TOKEN.EXPIRED
§Metadata Fields
Supports all metadata fields in any order:
description- Documentation stringintroduced- Version introduceddeprecated- Deprecation noticeexamples- Array of example error codestags- Array of category tags
§Examples
ⓘ
component! {
Auth, // Simple: "Auth"
Database { // With metadata
description: "Database operations",
introduced: "1.0.0",
tags: ["backend", "storage"],
},
}
// Generated code implements ComponentIdDocumented trait:
let desc = Component::Database.description(); // Trait method
let tags = Component::Database.tags();