Pair

Struct Pair 

Source
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

Source

pub fn new() -> Result<Self, Error>

Construct a new Pair.

Source

pub fn recv(&self, fd: RawFd) -> Result<Option<()>, Error>

Receive a new event. This function fails if the kernel returns an error.

Source

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§

Source§

impl Drop for Pair

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Pair

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.