pub trait SelectFn<I, T, S>: Send + 'staticwhere
T: ?Sized,{
// Required method
fn execute(&self, id: &I, data: &T) -> Result<S>;
}Expand description
Select function.
This trait defines a function that can be used to select data from an item, e.g., to extract a key to group items or to compute a duration for a timer.
There’s a range of different implementations of this trait, allowing you to
use a variety of function shapes, including support for Splat, as well
as support for the [WithId] and [WithSplat] adapters. Furthermore, the
trait can be implemented for custom types to add new behaviors. Note that
all implementations also allow to return a Report, which makes it
possible to return diagnostics from the function execution.
The 'static lifetimes is mandatory as closures must be moved into actions,
so requiring it here allows us to reduce the verbosity of trait bounds.
§Examples
Group by odd/even:
use zrx_stream::function::SelectFn;
// Define and execute function
let f = |&n: &i32| n & 1;
f.execute(&"id", &42)?;