Skip to main content

context

Attribute Macro context 

Source
#[context]
Expand description

Transforms a struct with permission-type fields into a capability context.

Generates:

  • Field types rewritten from PermType to Cap<PermType> (or SendCap<PermType>)
  • A new(root: &CapRoot) -> Self constructor
  • impl Has<P> for each field’s permission type

§Usage

#[capsec::context]
struct AppCtx {
    fs: FsRead,
    net: NetConnect,
}

// Send variant for async/threaded code:
#[capsec::context(send)]
struct AsyncCtx {
    fs: FsRead,
    net: NetConnect,
}