Skip to main content

Source

Trait Source 

Source
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§

Source

const MAX_EMITS: usize

The most rows the source emits for one owner (see Projection::MAX_EMITS).

Required Associated Types§

Source

type State: Send + Sync

State the source keeps beside the retained rows, such as a join index.

Required Methods§

Source

fn source_count(&self) -> usize

Number of entity collections the source reads.

Source

fn change_source(&self, slot: usize) -> ChangeSource

How changes reach collection slot.

Source

fn build_state(&self, solution: &S) -> Self::State

Builds the source state for solution.

Source

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.

Source

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.

Source

fn insert_entity_state( &self, solution: &S, state: &mut Self::State, slot: usize, entity_index: usize, )

Adds entity entity_index of collection slot to the source state.

Source

fn retract_entity_state( &self, solution: &S, state: &mut Self::State, slot: usize, entity_index: usize, )

Removes entity entity_index of collection slot from the source state.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<S, A, B, K, EA, EB, KA, KB, F, P, Out> Source<S, Out> for JoinedSource<S, A, B, K, EA, EB, KA, KB, F, P, Out>
where S: Send + Sync + 'static, A: Send + Sync + 'static, B: Send + Sync + 'static, K: Eq + Hash + Clone + Send + Sync + 'static, EA: CollectionExtract<S, Item = A>, EB: CollectionExtract<S, Item = B>, KA: Fn(&A) -> K + Send + Sync, KB: Fn(&B) -> K + Send + Sync, F: BiFilter<S, A, B>, P: Fn(&A, &B) -> Out + Send + Sync, Out: Send + Sync + 'static,

Source§

const MAX_EMITS: usize = 1

Source§

type State = JoinedState<K>