Skip to main content

task_fn

Function task_fn 

Source
pub fn task_fn<F, Args, FnArgs>(f: F) -> TaskFn<F, Args, FnArgs>
Expand description

A helper method to build a TaskFn from an async function or closure.

ยงExample

#[derive(Clone)]
struct State {
    // db: Arc<DatabaseConnection>,
}
async fn handler(id: u32, state: Data<State>) -> String {
    format!("Got id {} with state", id)
}   

This method can take functions with up to 16 additional arguments beyond the core request.

See Also: