Skip to main content

Module cap

Module cap 

Source
Expand description

The zero-sized capability token Cap<P> and its thread-safe variant SendCap<P>.

Cap<P> is the core proof type in capsec. Holding a Cap<FsRead> proves you have permission to read files. It is:

  • Zero-sized โ€” no runtime cost, erased at compilation
  • Unconstructible externally โ€” Cap::new() is pub(crate), so only CapRoot::grant can create them
  • !Send + !Sync โ€” scoped to the creating thread by default

Use make_send to explicitly opt into cross-thread transfer when needed (e.g., for tokio::spawn).

Structsยง

Cap
A zero-sized capability token proving the holder has permission P.
SendCap
A thread-safe capability token that can be sent across threads.