Skip to main content

AsyncEventPlugin

Trait AsyncEventPlugin 

Source
pub trait AsyncEventPlugin: Plugin + AsyncPluginExported {
    const ASYNC_EVENTS: &'static [&'static str];
    const EVENT_SOURCES: &'static [&'static str];

    // Required methods
    fn start_async(&mut self, handler: AsyncHandler) -> Result<(), Error>;
    fn stop_async(&mut self) -> Result<(), Error>;

    // Provided methods
    fn dump_state(&mut self, _handler: AsyncHandler) -> Result<(), Error> { ... }
    fn async_event<'a>(
        name: &'a CStr,
        data: &'a [u8],
    ) -> Event<AsyncEvent<'a, &'a [u8]>> { ... }
}
Expand description

Support for asynchronous event plugins

Required Associated Constants§

Source

const ASYNC_EVENTS: &'static [&'static str]

§Event names coming from this plugin

This constant contains a list describing the name list of all asynchronous events that this plugin is capable of pushing into a live event stream. The framework rejects async events produced by a plugin if their name is not on the name list returned by this function.

Source

const EVENT_SOURCES: &'static [&'static str]

§Event sources to attach asynchronous events to

This constant contains a list describing the event sources for which this plugin is capable of injecting async events in the event stream of a capture.

This is optional–if NULL or an empty array, then async events produced by this plugin will be injected in the event stream of any data source.

Note: one notable event source is called syscall

Required Methods§

Source

fn start_async(&mut self, handler: AsyncHandler) -> Result<(), Error>

§Start asynchronous event generation

When this method is called, your plugin should start whatever background mechanism is necessary (e.g. spawn a separate thread) and use the AsyncHandler::emit method to inject events to the main event loop.

Note: you must provide a mechanism to shut down the thread upon a call to AsyncEventPlugin::stop_async. This may involve e.g. a std::sync::Condvar that’s checked via std::sync::Condvar::wait_timeout by the thread.

Note: one notable event source is called syscall

Source

fn stop_async(&mut self) -> Result<(), Error>

§Stop asynchronous event generation

When this method is called, your plugin must stop the background mechanism started by AsyncEventPlugin::start_async and wait for it to finish (no calls to AsyncHandler::emit are permitted after this method returns).

Note: AsyncEventPlugin::start_async can be called again, with a different AsyncHandler.

Provided Methods§

Source

fn dump_state(&mut self, _handler: AsyncHandler) -> Result<(), Error>

§Dump the plugin state as a series of async events

When this method is called, your plugin may save its state via a series of async events that will be replayed when a capture file is loaded.

The default implementation does nothing.

Source

fn async_event<'a>( name: &'a CStr, data: &'a [u8], ) -> Event<AsyncEvent<'a, &'a [u8]>>

§A helper method to create an asynchronous event

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§