component

Macro component 

Source
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.EXPIRED not E.AUTH.TOKEN.EXPIRED

§Metadata Fields

Supports all metadata fields in any order:

  • description - Documentation string
  • introduced - Version introduced
  • deprecated - Deprecation notice
  • examples - Array of example error codes
  • tags - 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();