pub struct First<G> { /* private fields */ }Expand description
Try policies in order and grant the value paired with the first one that accepts. When none accepts, the last policy’s reason is returned, so put the broadest policy last.
use kunobi_daemon::{
ProcessId,
peer::{Credentials, ExpectedProcess, First, Policy, SameUser},
};
#[derive(Clone, Debug, PartialEq)]
enum View { Full, Redacted }
let app = ProcessId::new(42);
let policy = First::new()
.then(ExpectedProcess::new(move || app), View::Full)
.then(SameUser, View::Redacted);
assert_eq!(policy.grant(&Credentials::new(app, true)), Ok(View::Full));
assert_eq!(policy.grant(&Credentials::new(ProcessId::new(7), true)), Ok(View::Redacted));
assert!(policy.grant(&Credentials::new(app, false)).is_err());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<G> !RefUnwindSafe for First<G>
impl<G> !UnwindSafe for First<G>
impl<G> Freeze for First<G>
impl<G> Send for First<G>
impl<G> Sync for First<G>
impl<G> Unpin for First<G>
impl<G> UnsafeUnpin for First<G>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more