Skip to main content

Engine

Trait Engine 

Source
pub trait Engine {
    type Loader: Loader<Component = Self> + Default;

    const EBPF_BYTES: &'static [u8];
    const EBPF_PROGRAM_NAME: &'static str;

    // Required methods
    fn capacity(&self) -> Option<usize>;
    fn add_rule(&mut self, rule_id: RuleId, rule: &Rule) -> Result<(), Error>;
    fn remove_rule(&mut self, rule_id: RuleId, rule: &Rule) -> Result<(), Error>;
}
Expand description

The Engine trait defines how rules are evaluated in the eBPF program. Each Engine requires a matching eBPF program.

Required Associated Constants§

Source

const EBPF_BYTES: &'static [u8]

The raw bytes of the eBPF program

Source

const EBPF_PROGRAM_NAME: &'static str

The eBPF program name

Required Associated Types§

Source

type Loader: Loader<Component = Self> + Default

A type corresponding to the Engine’s Loader. This is responsible for collecting configuration and generating the Engine.

Required Methods§

Source

fn capacity(&self) -> Option<usize>

If this engnine is limited in max capacity, return the capcacity

Source

fn add_rule(&mut self, rule_id: RuleId, rule: &Rule) -> Result<(), Error>

Add a rule to the engine

§Errors

Returns Error::EngineAtCapacity if the engine cannot accept additional rules. Returns additional errors depending on the engine implementation.

Source

fn remove_rule(&mut self, rule_id: RuleId, rule: &Rule) -> Result<(), Error>

Remove a rule from the engine

§Errors

Returns Error::MissingRule if the rule id is not present in the filter. Returns additional errors depending on the engine implementation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§