Skip to main content

Guard

Trait Guard 

Source
pub trait Guard {
    // Required method
    fn check(&self, request: &RequestHead) -> bool;

    // Provided method
    fn fmt(&self, f: &mut Formatter<'_>) -> Result { ... }
}
Expand description

Trait defines resource guards. Guards are used for route selection.

Guards can not modify the request object. But it is possible to store extra attributes on a request by using the Extensions container. Extensions containers are available via the RequestHead::extensions() method.

Required Methods§

Source

fn check(&self, request: &RequestHead) -> bool

Check if request matches predicate

Provided Methods§

Source

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Debug format

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Guard for AllGuard

Source§

impl Guard for AnyGuard

Source§

impl<F> Guard for F
where F: Fn(&RequestHead) -> bool,