pub trait CacheableFn<Args>: 'static {
type Output;
type Future: Future<Output = Result<Self::Output>> + 'static;
// Required method
fn call_with(&self, args: Args) -> Self::Future;
}Expand description
A server function (or any async fn returning dioxus::Result) that can
be passed by name to use_cached and
invalidate_cached.
Implemented for functions of up to eight arguments. Args is the
arguments as a tuple, which Rust infers from the function:
ⓘ
async fn get_bookmarks() -> dioxus::Result<Vec<Media>>; // Args = ()
async fn get_media(id: String) -> dioxus::Result<Media>; // Args = (String,)
async fn get_reviews(id: String, page: u32) -> dioxus::Result<_>; // Args = (String, u32)Only pass function items. A closure compiles, but panics on first use: its type name cannot tell two different reads apart.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".