#access-control #permissions #capabilities #arceos

no-std cap_access

Provide basic capability-based access control to objects

1 unstable release

0.1.0 Jul 17, 2024

#6 in #permission

Download history 512/week @ 2024-09-05 218/week @ 2024-09-12 284/week @ 2024-09-19 234/week @ 2024-09-26 194/week @ 2024-10-03 798/week @ 2024-10-10 1143/week @ 2024-10-17 485/week @ 2024-10-24 83/week @ 2024-10-31 248/week @ 2024-11-07 391/week @ 2024-11-14 339/week @ 2024-11-21 231/week @ 2024-11-28 381/week @ 2024-12-05 371/week @ 2024-12-12 588/week @ 2024-12-19

1,701 downloads per month

GPL-3.0-or-later OR Apache-2…

6KB

cap_access

Crates.io Docs.rs CI

Provide basic capability-based access control to objects.

The wrapper type WithCap associates a capability to an object, that is a set of access rights. When accessing the object, we must explicitly specify the access capability, and it must not violate the capability associated with the object at initialization.

Examples

use cap_access::{Cap, WithCap};

let data = WithCap::new(42, Cap::READ | Cap::WRITE);

// Access with the correct capability.
assert_eq!(data.access(Cap::READ).unwrap(), &42);
assert_eq!(data.access(Cap::WRITE).unwrap(), &42);
assert_eq!(data.access(Cap::READ | Cap::WRITE).unwrap(), &42);

// Access with the incorrect capability.
assert!(data.access(Cap::EXECUTE).is_none());
assert!(data.access(Cap::READ | Cap::EXECUTE).is_none());

Dependencies

~105KB