#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

#621 in Operating systems

Download history 522/week @ 2024-07-29 206/week @ 2024-08-05 219/week @ 2024-08-12 105/week @ 2024-08-19 184/week @ 2024-08-26 397/week @ 2024-09-02 419/week @ 2024-09-09 227/week @ 2024-09-16 370/week @ 2024-09-23 104/week @ 2024-09-30 509/week @ 2024-10-07 1132/week @ 2024-10-14 676/week @ 2024-10-21 320/week @ 2024-10-28 77/week @ 2024-11-04 285/week @ 2024-11-11

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