[][src]Module act_zero::async_fn

This module contains tools for dealing with async functions. These are similar to the FnOnce trait from std, but they allow the lifetime of the returned future to be bound by the lifetime of the argument. The different variants correspond to the different reference types (&T, &mut T) but all variants consume self like FnOnce.

For simplicity, only one argument is allowed. In addition, the returned future and its output are assumed to be Send + 'static.

Note: typically you will not need to use these tools. The exist primarily for use by the expanded macro code from #[act_zero].

Structs

AsyncMap

Return type of AsyncFnOnce::map and AsyncMutFnOnce::map.

BindOutput

Return type of AsyncFnOnce::bind_output and AsyncMutFnOnce::bind_output.

Closure

Rust does not support async closures, and is incapable of inferring the correct lifetimes for closures returning an async move { ... } block which captures a non-'static argument to the closure. To solve this problem, we introduce this explicit closure type, which takes a stand-alone async fn expecting two arguments, and binds the second argument to a closure "upvar" passed in at construction.

Traits

AsyncFnOnce

Trait for async methods which take &T as the argument type.

AsyncMutFnOnce

Trait for async methods which take &mut T as the argument type.

ClosureFn

We can't even directly express the lifetime bounds of an async fn directly, so we are forced to introduce a trait just to write the required bounds. This trait is for the case when the first argument is &T.

ClosureFnMut

We can't even directly express the lifetime bounds of an async fn directly, so we are forced to introduce a trait just to write the required bounds. This trait is for the case when the first argument is &mut T.