Function wlan_hw_sim::event::extract

source ·
pub fn extract<S, E, Z, F>(
    f: F
) -> impl Handler<S, E, Output = <Extract<Z, F> as Handler<S, E>>::Output>
where Extract<Z, F>: Handler<S, E>,
Expand description

Constructs an extractor event handler that runs and matches when its parameters can be extracted from an event.

An extractor executes when the arguments of its composed function can be constructed from an event. This both routes events within an event handler and extracts the necessary data for a handler declaratively without the need for the handler to destructure, convert, nor reference data in an ad-hoc manner.

§Examples

The following constructs an event handler that runs and matches when an authentication management frame can be extracted from a transmission event.

let mut handler = event::on_transmit(event::extract(|frame: Buffered<AuthFrame>| {
    let frame = frame.get();
    assert_eq!(
        { frame.auth_hdr.status_code },
        StatusCode::Success.into(),
    );
}));