pub trait Process<B: FirewallBackend>{
// 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§
Sourcefn process(&self, ctx: &ProcessContext<'_, B>) -> Result<Option<Vec<B::Rule>>>
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".