Trait Filter

Source
pub trait Filter<T>: Clone {
    // Required method
    fn matches(&self, item: &T) -> bool;
}
Expand description

A filter that allows a service to be executed based on a condition

§Example


#[derive(Debug, Clone)]
struct MyFilter;

impl<T> Filter<T> for MyFilter {
    fn matches(&self, _: &T) -> bool {
        true
    }
}

let filter = MyFilter;
assert_eq!(filter.matches(&()), true);

Required Methods§

Source

fn matches(&self, item: &T) -> bool

Whether the service should be executed

If true, the service will be executed, otherwise it will fall through to the next service.

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§