pub trait Query: Clone {
    type State;
    type Item: HasValidationStatus;
    type Output;

    // Required methods
    fn init_fold(&self) -> StateQueryResult<Self::State>;
    fn as_map(&self) -> Arc<dyn Fn(&Row<'_>) -> StateQueryResult<Self::Item>>;
    fn fold(
        &self,
        state: Self::State,
        data: Self::Item
    ) -> StateQueryResult<Self::State>;
    fn render<S>(
        &self,
        state: Self::State,
        stores: S
    ) -> StateQueryResult<Self::Output>
       where S: Store;

    // Provided methods
    fn query(&self) -> String { ... }
    fn params(&self) -> Vec<Params<'_>> { ... }
    fn as_filter(&self) -> Box<dyn Fn(&QueryData<Self>) -> bool> { ... }
    fn run<S>(&self, stores: S) -> StateQueryResult<Self::Output>
       where S: Stores<Self> + Store { ... }
}
Expand description

You should keep your query type cheap to clone. If there is any large data put it in an Arc.

Required Associated Types§

Required Methods§

source

fn init_fold(&self) -> StateQueryResult<Self::State>

source

fn as_map(&self) -> Arc<dyn Fn(&Row<'_>) -> StateQueryResult<Self::Item>>

source

fn fold( &self, state: Self::State, data: Self::Item ) -> StateQueryResult<Self::State>

source

fn render<S>( &self, state: Self::State, stores: S ) -> StateQueryResult<Self::Output>
where S: Store,

Provided Methods§

source

fn query(&self) -> String

source

fn params(&self) -> Vec<Params<'_>>

source

fn as_filter(&self) -> Box<dyn Fn(&QueryData<Self>) -> bool>

source

fn run<S>(&self, stores: S) -> StateQueryResult<Self::Output>
where S: Stores<Self> + Store,

Object Safety§

This trait is not object safe.

Implementors§