pub trait Source<S, Out>: Send + Sync {
type State: Send + Sync;
const MAX_EMITS: usize;
// Required methods
fn source_count(&self) -> usize;
fn change_source(&self, slot: usize) -> ChangeSource;
fn build_state(&self, solution: &S) -> Self::State;
fn collect_all<V>(&self, solution: &S, state: &Self::State, visit: V)
where V: FnMut(RowCoordinate, Out);
fn collect_entity<V>(
&self,
solution: &S,
state: &Self::State,
slot: usize,
entity_index: usize,
visit: V,
)
where V: FnMut(RowCoordinate, Out);
fn insert_entity_state(
&self,
solution: &S,
state: &mut Self::State,
slot: usize,
entity_index: usize,
);
fn retract_entity_state(
&self,
solution: &S,
state: &mut Self::State,
slot: usize,
entity_index: usize,
);
}Expand description
The producer behind a projected stream: one or more entity collections and the rows they project to.
A projected stream’s operator tree retains rows by RowCoordinate and,
on an entity notification, asks the source for that entity’s rows again.
Single-source projections, filters, merges and joined pairs implement it;
the fluent project, filter, merge and join methods build them.
Required Associated Constants§
Sourceconst MAX_EMITS: usize
const MAX_EMITS: usize
The most rows the source emits for one owner (see
Projection::MAX_EMITS).
Required Associated Types§
Required Methods§
Sourcefn source_count(&self) -> usize
fn source_count(&self) -> usize
Number of entity collections the source reads.
Sourcefn change_source(&self, slot: usize) -> ChangeSource
fn change_source(&self, slot: usize) -> ChangeSource
How changes reach collection slot.
Sourcefn build_state(&self, solution: &S) -> Self::State
fn build_state(&self, solution: &S) -> Self::State
Builds the source state for solution.
Sourcefn collect_all<V>(&self, solution: &S, state: &Self::State, visit: V)where
V: FnMut(RowCoordinate, Out),
fn collect_all<V>(&self, solution: &S, state: &Self::State, visit: V)where
V: FnMut(RowCoordinate, Out),
Visits every row of solution with its coordinate.
Sourcefn collect_entity<V>(
&self,
solution: &S,
state: &Self::State,
slot: usize,
entity_index: usize,
visit: V,
)where
V: FnMut(RowCoordinate, Out),
fn collect_entity<V>(
&self,
solution: &S,
state: &Self::State,
slot: usize,
entity_index: usize,
visit: V,
)where
V: FnMut(RowCoordinate, Out),
Visits the rows owned by entity entity_index of collection slot.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".