Trait holochain_state::query::Query
source · 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§
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>
Object Safety§
This trait is not object safe.