Expand description
§capsec-core
Zero-cost capability tokens and permission traits for compile-time capability-based security in Rust.
This crate provides the foundational types that the rest of the capsec
ecosystem builds on:
Permission— sealed marker trait for capability categoriesCap<P>— zero-sized proof token that the holder has permissionPHas<P>— trait for checking and composing capabilitiesCapRoot— the singleton root of all capability grantsAttenuated<P, S>— scope-restricted capabilitiesCapSecError— error types for scope violations and I/O
All capability types are zero-sized at runtime. The security model is enforced entirely through the type system — no runtime overhead.
§Quick start
ⓘ
use capsec_core::root::test_root;
use capsec_core::permission::{FsRead, NetConnect};
use capsec_core::has::Has;
// Create a capability root (use test_root in tests)
let root = test_root();
// Grant individual capabilities
let fs_cap = root.grant::<FsRead>();
let net_cap = root.grant::<NetConnect>();
// Functions declare what they need via Has<P> bounds
fn needs_both(fs: &impl Has<FsRead>, net: &impl Has<NetConnect>) {
let _ = fs.cap_ref();
let _ = net.cap_ref();
}
needs_both(&fs_cap, &net_cap);Modules§
- attenuate
- Scope-restricted capabilities via
Attenuated<P, S>. - cap
- The zero-sized capability token
Cap<P>and its thread-safe variantSendCap<P>. - error
- Error types for the capsec capability system.
- has
- The
Has<P>trait — proof that a capability token includes permissionP. - permission
- The sealed
Permissiontrait and all built-in permission types. - root
- The capability root — the single point where ambient authority enters the system.