#access-control #permissions #arceos #capabilities

no-std cap_access

Provide basic capability-based access control to objects

1 unstable release

0.1.0 Jul 17, 2024

#523 in Operating systems

Download history 213/week @ 2024-07-13 353/week @ 2024-07-20 519/week @ 2024-07-27 174/week @ 2024-08-03 233/week @ 2024-08-10 157/week @ 2024-08-17 183/week @ 2024-08-24 282/week @ 2024-08-31

858 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