falco_plugin/plugin/event/
mod.rs

1mod async_event;
2mod event_input;
3mod json;
4mod plugin_event;
5
6pub use async_event::AsyncEvent;
7pub use event_input::EventInput;
8use falco_event::fields::{FromBytes, ToBytes};
9pub use json::JsonPayload;
10pub use plugin_event::PluginEvent;
11use std::fmt::Debug;
12
13/// Provide an event source name for an event type
14///
15/// This is required to use that type as an event payload
16pub trait EventSource {
17    /// Source name
18    ///
19    /// `syscall` for system call events, an arbitrary string (matching the one in the source plugin
20    /// implementation) for custom plugin/async events
21    const SOURCE: Option<&'static str>;
22}
23
24impl EventSource for &[u8] {
25    const SOURCE: Option<&'static str> = None;
26}
27
28/// A generic enum for custom plugin/async event payloads
29///
30/// Type parameters:
31/// - `P` specifies the payload of the `Plugin` variant
32/// - `A` specifies the payload of the `Async` variant
33#[derive(falco_event::AnyEvent)]
34#[allow(missing_docs)]
35pub enum AnyPluginEvent<'a, P, A>
36where
37    for<'b> P: EventSource + ToBytes + FromBytes<'b> + Debug,
38    A: EventSource + ToBytes + FromBytes<'a> + Debug,
39{
40    Plugin(PluginEvent<P>),
41    Async(AsyncEvent<'a, A>),
42}