pub struct Pair { /* private fields */ }Expand description
A Notification Pair.
§Examples
ⓘ
let pair = seccomp::notify::Pair::new().unwrap();
loop {
match pair.recv(raw) {
Ok(Some(_)) => pair.reply(raw, |req, resp| {
resp.val = 0;
// Deny syscall 1.
resp.error = if req.data.nr == 1 {
EPERM
} else {
0
};
// Allow everything else.
resp.flags = 1;
}).unwrap(),
Ok(None) => continue,
Err(_) => break
}
}Implementations§
Source§impl Pair
impl Pair
Sourcepub fn recv(&self, fd: RawFd) -> Result<Option<()>, Error>
pub fn recv(&self, fd: RawFd) -> Result<Option<()>, Error>
Receive a new event. This function fails if the kernel returns an error.
Sourcepub fn reply<F>(&self, fd: RawFd, handle: F) -> Result<(), Error>
pub fn reply<F>(&self, fd: RawFd, handle: F) -> Result<(), Error>
Reply to the last event.
§Handle
Handle offloads the actual decision of the request to your application. It takes a constant reference to the event from the kernel, and a mutable reference to the response. Parse the former to populate the latter, and the Pair will send the response over.
The request will always be valid, and the ID will already be set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pair
impl RefUnwindSafe for Pair
impl !Sync for Pair
impl Unpin for Pair
impl UnwindSafe for Pair
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