Skip to main content

FnContextStatic

Trait FnContextStatic 

Source
pub trait FnContextStatic<Fut, T>: FnContext<Fut> + 'static
where Fut: Future<Output = T> + Send,
{ }
Expand description

A trait for static, sendable, synchronous functions that return a future.

This trait ensures that a hook function is safe to be sent across threads and has a static lifetime, making it suitable for use in long-lived components of the application, such as the main router.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F, Fut, T> FnContextStatic<Fut, T> for F
where F: FnContext<Fut> + 'static, Fut: Future<Output = T> + Send,

A blanket implementation for static, sendable, synchronous functions that return a future.

This trait is used for handlers that are known at compile time, ensuring they are safe to be sent across threads and have a static lifetime. This is crucial for handlers that are part of the application’s long-lived state.