pub trait AsyncLocal<T>where
    T: 'static + AsContext,
{ type impl_trait_with_async_0<'async_trait, F, R: 'async_trait, Fut>: Future<Output = R> + 'async_trait + Send
    where
        F: FnOnce(RefGuard<'async_trait, T::Target>) -> Fut + Send + 'async_trait,
        Fut: Future<Output = R> + Send + 'async_trait,
        T: 'async_trait,
        Self: 'static
; fn with_async<'async_trait, F, R: 'async_trait, Fut>(
        &'static self,
        f: F
    ) -> Self::impl_trait_with_async_0<'async_trait, F, R, Fut>
    where
        F: FnOnce(RefGuard<'async_trait, T::Target>) -> Fut + Send + 'async_trait,
        Fut: Future<Output = R> + Send + 'async_trait
; fn with_blocking<F, R>(&'static self, f: F) -> JoinHandle<R>
    where
        F: for<'a> FnOnce(RefGuard<'a, T::Target>) -> R + Send + 'static,
        R: Send + 'static
; unsafe fn local_ref(&'static self) -> LocalRef<T::Target>; unsafe fn guarded_ref<'a>(&'static self) -> RefGuard<'a, T::Target>; }
Expand description

LocalKey extension for creating thread-safe pointers to thread-local Context

Required Associated Types§

Required Methods§

The async counterpart of LocalKey::with

Available on crate features tokio-runtime or async-std-runtime only.

A wrapper around spawn_blocking that appropriately constrains the lifetime of RefGuard

Use the tokio-runtime feature flag for tokio::task::spawn_blocking or async-std-runtime for async_std::task::spawn_blocking

Create a thread-safe pointer to a thread local Context

Safety

The only safe way to use LocalRef is within the context of an async runtime:

Create a lifetime-constrained thread-safe pointer to a thread local Context

Safety

The only safe way to use RefGuard is within the context of an async runtime:

Implementations on Foreign Types§

Available on crate features tokio-runtime or async-std-runtime only.

Implementors§