Skip to main content

capability

Attribute Macro capability 

Source
#[capability]
Expand description

Declare a Capable marker type backed by a Capability constant.

Generates the struct, a hidden Capability constant, and the Capable impl so the marker can be used with doxa_auth::Require<M> immediately. Requires doxa-policy in the consumer’s dependency tree.

§Attribute arguments

  • name = "scope.name" — the stable client-facing capability identifier.
  • description = "Human-readable description" — displayed in UI badges.
  • checks(action = "...", entity_type = "...", entity_id = "...") — one or more check blocks. All must pass for the capability to be granted.

§Example

use doxa::capability;

#[capability(
    name = "widgets.read",
    description = "Read widget definitions",
    checks(action = "read", entity_type = "Widget", entity_id = "collection"),
)]
pub struct WidgetsRead;