#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

#542 in Operating systems

Download history 123/week @ 2024-08-18 178/week @ 2024-08-25 346/week @ 2024-09-01 474/week @ 2024-09-08 231/week @ 2024-09-15 343/week @ 2024-09-22 115/week @ 2024-09-29 471/week @ 2024-10-06 1098/week @ 2024-10-13 742/week @ 2024-10-20 329/week @ 2024-10-27 84/week @ 2024-11-03 258/week @ 2024-11-10 485/week @ 2024-11-17 265/week @ 2024-11-24 402/week @ 2024-12-01

1,427 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