cap_access

Crates.iocap_access
lib.rscap_access
version0.1.0
sourcesrc
created_at2024-07-17 09:25:22.298921
updated_at2024-07-17 09:25:22.298921
descriptionProvide basic capability-based access control to objects
homepagehttps://github.com/arceos-org/arceos
repositoryhttps://github.com/arceos-org/cap_access
max_upload_size
id1306040
size7,515
core (github:arceos-org:core)

documentation

https://docs.rs/cap_access

README

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());
Commit count: 0

cargo fmt