Skip to main content

Query

Trait Query 

Source
pub trait Query<S>:
    Clone
    + PartialEq
    + 'static {
    type Output: 'static;

    // Required method
    fn run(
        self,
        state: S,
    ) -> impl Future<Output = Result<Self::Output, RouteError>> + 'static;

    // Provided method
    fn depends(&self) -> Vec<String> { ... }
}
Expand description

Async data that views read with Remote::query, cached by value.

The type is the query and its value the input: SearchAuthors("fe".into()) and SearchAuthors("fer".into()) are two entries of the same query, and every view reading an equal value shares one result.

Required Associated Types§

Source

type Output: 'static

Required Methods§

Source

fn run( self, state: S, ) -> impl Future<Output = Result<Self::Output, RouteError>> + 'static

Fetches the data, with a clone of the app state.

Provided Methods§

Source

fn depends(&self) -> Vec<String>

Reruns the query when one of these keys is invalidated, like Page::depends.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§