Skip to main content

Process

Trait Process 

Source
pub trait Process<B: FirewallBackend>
where DFW<B>: Process<B>,
{ // Required method fn process( &self, ctx: &ProcessContext<'_, B>, ) -> Result<Option<Vec<B::Rule>>>; }
Expand description

This trait allows a type to define its own processing rules. It is expected to return a list of rules that can be applied with nft.

§Example

struct MyBackend;
impl FirewallBackend for MyBackend {
    type Rule = String;

    fn apply(rules: Vec<String>, ctx: &ProcessContext<Self>) -> Result<(), Error> {
        // Write code to apply the processed rules.
    }
}
struct MyType {
    rules: Vec<String>,
}

impl Process<MyBackend> for MyType {
    fn process(&self, ctx: &ProcessContext<MyBackend>) -> Result<Option<Vec<String>>, Error> {
        let mut rules = Vec::new();
        for rule in &self.rules {
            rules.push(format!("add rule {}", rule));
        }
        Ok(Some(rules))
    }
}

Required Methods§

Source

fn process(&self, ctx: &ProcessContext<'_, B>) -> Result<Option<Vec<B::Rule>>>

Process the current type within the given ProcessContext, returning zero or more rules to apply with nft.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<B, T> Process<B> for Option<T>
where B: FirewallBackend, DFW<B>: Process<B>, T: Process<B>,

Source§

fn process(&self, ctx: &ProcessContext<'_, B>) -> Result<Option<Vec<B::Rule>>>

Source§

impl<B, T> Process<B> for Vec<T>
where B: FirewallBackend, DFW<B>: Process<B>, T: Process<B>,

Source§

fn process(&self, ctx: &ProcessContext<'_, B>) -> Result<Option<Vec<B::Rule>>>

Implementors§