Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Expand description

A builder for Handles.

This is used to maintain a live view over mutable configuration, and is best suited for cases where the Waf’s configuration evolves regularly, such as through remote configuration.

Implementations§

Source§

impl Builder

Source

pub fn new(config: &Config) -> Option<Self>

Creates a new Builder instance using the provided Config. Returns None if the builder’s initialization fails.

Source

pub fn add_or_update_config( &mut self, path: &str, ruleset: &impl AsRef<ddwaf_object>, diagnostics: Option<&mut WafOwned<WafMap>>, ) -> bool

Adds or updates the configuration for the given path.

Returns true if the ruleset was successfully added or updated. Any warning/error information is conveyed through the provided diagnostics object.

§Panics

Panics if the provided path is longer than u32::MAX bytes.

Source

pub fn remove_config(&mut self, path: &str) -> bool

Removes the configuration for the given path if some exists.

Returns true if some configuration was indeed removed.

§Panics

Panics if the provided path is longer than u32::MAX bytes.

Source

pub fn config_paths_count(&mut self, filter: Option<&str>) -> u32

Returns the number of configuration paths currently loaded in this Builder, optionally filtered by a regular expression.

§Panics

Panics if the provided filter regular expression is longer than u32::MAX bytes.

Source

pub fn config_paths(&mut self, filter: Option<&str>) -> WafOwned<WafArray>

Returns the configuration paths currently loaded in this Builder, optionally filtered by a regular expression.

§Panics

Panics if the provided filter regular expression is longer than u32::MAX bytes.

Source

pub fn build(&mut self) -> Option<Handle>

Builds a new Handle from the current configuration in this Builder.

Returns None if the builder fails to create a new Handle, meaning the current configuration contains no active instructions (no rules nor processors are available).

Trait Implementations§

Source§

impl Drop for Builder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Builder

Source§

impl Sync for Builder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.