Skip to main content

Handler

Trait Handler 

Source
pub trait Handler:
    Send
    + Sync
    + 'static {
    // Required method
    fn handle<'a>(
        &'a self,
        cx: &'a HandlerCtx,
    ) -> Pin<Box<dyn Future<Output = NotifAction> + Send + 'a>>;
}
Expand description

Public extension trait for sandlock seccomp-notif handlers.

Each implementor is registered against a crate::seccomp::syscall::Syscall through crate::Sandbox::run_with_handlers / crate::Sandbox::run_interactive_with_handlers. Receives &HandlerCtx borrowed for the call; cannot outlive the dispatch invocation.

State lives on the implementor — no Arc::clone ladders, no closure ceremony at registration time.

handle returns a boxed Future so the trait stays dyn-compatible (the supervisor stores user handlers as Vec<Arc<dyn Handler>>, keyed by syscall number). Returning impl Future directly via RPITIT would be more efficient but is not object-safe, and changing the storage to a non-erased shape would force a generic dispatch chain incompatible with arbitrary user handler types.

Required Methods§

Source

fn handle<'a>( &'a self, cx: &'a HandlerCtx, ) -> Pin<Box<dyn Future<Output = NotifAction> + Send + 'a>>

Trait Implementations§

Source§

impl Handler for Box<dyn Handler>

Source§

fn handle<'a>( &'a self, cx: &'a HandlerCtx, ) -> Pin<Box<dyn Future<Output = NotifAction> + Send + 'a>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Handler for Box<dyn Handler>

Source§

fn handle<'a>( &'a self, cx: &'a HandlerCtx, ) -> Pin<Box<dyn Future<Output = NotifAction> + Send + 'a>>

Source§

impl Handler for Arc<dyn Handler>

Source§

fn handle<'a>( &'a self, cx: &'a HandlerCtx, ) -> Pin<Box<dyn Future<Output = NotifAction> + Send + 'a>>

Implementors§

Source§

impl<F, Fut> Handler for F
where F: Fn(&HandlerCtx) -> Fut + Send + Sync + 'static, Fut: Future<Output = NotifAction> + Send + 'static,