Skip to main content

define_capability_type

Macro define_capability_type 

Source
macro_rules! define_capability_type {
    ($type:ident: $($T:path),+ $(,)?) => { ... };
}
Expand description

Define a struct type that implements the given capability traits.

Unlike create_capability! or create_typed_capability!, this macro only defines a visibly named type, it does not create any instances. Use this when you need to name the capability type across scope boundaries.

Use [mint_defined_capability!] to create an instance. Note: You can only mint capabilities in the module that defines this type, or in a descendant of that module.

This macro is intended to be used at module level scope (i.e. not in a code block), since minting requires naming the type across a scope boundary.

§Usage Example


define_capability_type!(ProcCapForManager: ProcessManagementCapability);

§Restrictions

This helper macro cannot be called from #![forbid(unsafe_code)] crates, and is used by trusted code to define a capability type.

§Safety

This macro can only be used in a context that is allowed to use unsafe. Specifically, an internal allow(unsafe_code) directive will conflict with any forbid(unsafe_code) at the crate or block level.