pub struct UniConstraintStream<S, A, E, F, Sc>where
Sc: Score,{ /* private fields */ }Expand description
Zero-erasure constraint stream over a single entity type.
UniConstraintStream accumulates filters and can be finalized into
an IncrementalUniConstraint via penalize() or reward().
All type parameters are concrete - no trait objects, no Arc allocations in the hot path.
§Type Parameters
S- Solution typeA- Entity typeE- Extractor function typeF- Combined filter typeSc- Score type
Implementations§
Source§impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
Sourcepub fn project<P>(
self,
projection: P,
) -> Stream<S, P::Out, SingleSource<S, A, E, F, P, P::Out>, TrueFilter, Sc>where
P: Projection<A> + 'static,
pub fn project<P>(
self,
projection: P,
) -> Stream<S, P::Out, SingleSource<S, A, E, F, P, P::Out>, TrueFilter, Sc>where
P: Projection<A> + 'static,
Projects each entity that passes the stream filter into zero or more Out
rows emitted by projection.
Source§impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>where
S: Send + Sync + 'static,
A: UnassignedEntity<S>,
E: CollectionExtract<S, Item = A>,
F: UniFilter<S, A>,
Sc: Score + 'static,
impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>where
S: Send + Sync + 'static,
A: UnassignedEntity<S>,
E: CollectionExtract<S, Item = A>,
F: UniFilter<S, A>,
Sc: Score + 'static,
Sourcepub fn unassigned(
self,
) -> UniConstraintStream<S, A, E, AndUniFilter<F, FnUniFilter<fn(&S, &A) -> bool>>, Sc>
pub fn unassigned( self, ) -> UniConstraintStream<S, A, E, AndUniFilter<F, FnUniFilter<fn(&S, &A) -> bool>>, Sc>
Keeps only entities whose planning variable is unassigned, as reported by
the macro-generated UnassignedEntity impl.
Source§impl<S, A, E, Sc> UniConstraintStream<S, A, E, TrueFilter, Sc>
impl<S, A, E, Sc> UniConstraintStream<S, A, E, TrueFilter, Sc>
Source§impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
Sourcepub fn flattened<B, Flat>(
self,
flatten: Flat,
) -> FlattenedCollectionTarget<S, A, B, E, F, FlattenVecExtract<Flat>, Sc>
pub fn flattened<B, Flat>( self, flatten: Flat, ) -> FlattenedCollectionTarget<S, A, B, E, F, FlattenVecExtract<Flat>, Sc>
Flattens each entity into the children flatten returns, as the right side
of if_exists or if_not_exists.
Children are read from the solution and never become rows.
Sourcepub fn filter<P>(
self,
predicate: P,
) -> UniConstraintStream<S, A, E, AndUniFilter<F, FnUniFilter<impl Fn(&S, &A) -> bool + Send + Sync>>, Sc>
pub fn filter<P>( self, predicate: P, ) -> UniConstraintStream<S, A, E, AndUniFilter<F, FnUniFilter<impl Fn(&S, &A) -> bool + Send + Sync>>, Sc>
Adds a filter predicate to the stream.
Sourcepub fn join<J>(self, target: J) -> J::Outputwhere
J: JoinTarget<S, A, E, F, Sc>,
pub fn join<J>(self, target: J) -> J::Outputwhere
J: JoinTarget<S, A, E, F, Sc>,
Joins this stream using the provided join target.
First keyed equality cross-joins apply this stream’s accumulated unary filter as source membership before key extraction and pair creation. Post-join filters operate on joined rows. Other join dispatches do not receive this left-source filter pushdown.
Sourcepub fn group_by<K, KF, C, V, R, Acc>(
self,
key_fn: KF,
collector: C,
) -> GroupedConstraintStream<S, A, K, E, F, KF, C, V, R, Acc, Sc>
pub fn group_by<K, KF, C, V, R, Acc>( self, key_fn: KF, collector: C, ) -> GroupedConstraintStream<S, A, K, E, F, KF, C, V, R, Acc, Sc>
Groups entities by key and aggregates with a collector.
Source§impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
Sourcepub fn if_exists<T>(self, target: T) -> T::Outputwhere
T: ExistenceTarget<S, A, E, F, Sc>,
pub fn if_exists<T>(self, target: T) -> T::Outputwhere
T: ExistenceTarget<S, A, E, F, Sc>,
Keeps entities that have at least one match in target, typically
(other_stream, equal_bi(left_key, right_key)).
Sourcepub fn if_not_exists<T>(self, target: T) -> T::Outputwhere
T: ExistenceTarget<S, A, E, F, Sc>,
pub fn if_not_exists<T>(self, target: T) -> T::Outputwhere
T: ExistenceTarget<S, A, E, F, Sc>,
Keeps entities that have no match in target, typically
(other_stream, equal_bi(left_key, right_key)).
Source§impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
impl<S, A, E, F, Sc> UniConstraintStream<S, A, E, F, Sc>
Sourcepub fn penalize<W>(
self,
weight: W,
) -> UniConstraintBuilder<S, A, E, F, impl Fn(&A) -> Sc + Send + Sync, Sc>
pub fn penalize<W>( self, weight: W, ) -> UniConstraintBuilder<S, A, E, F, impl Fn(&A) -> Sc + Send + Sync, Sc>
Penalizes each match by weight.
weight is a fixed score, or a closure over the matched entity returning one.
A fixed weight with a non-zero hard level marks the constraint hard; closures
are soft unless wrapped in hard_weight.
Sourcepub fn reward<W>(
self,
weight: W,
) -> UniConstraintBuilder<S, A, E, F, impl Fn(&A) -> Sc + Send + Sync, Sc>
pub fn reward<W>( self, weight: W, ) -> UniConstraintBuilder<S, A, E, F, impl Fn(&A) -> Sc + Send + Sync, Sc>
Rewards each match by weight.
weight is a fixed score, or a closure over the matched entity returning one.
A fixed weight with a non-zero hard level marks the constraint hard; closures
are soft unless wrapped in hard_weight.
Trait Implementations§
Source§impl<S, A, E, F, Sc> CollectionExtract<S> for UniConstraintStream<S, A, E, F, Sc>
impl<S, A, E, F, Sc> CollectionExtract<S> for UniConstraintStream<S, A, E, F, Sc>
Source§fn contains(&self, s: &S, item: &A) -> bool
fn contains(&self, s: &S, item: &A) -> bool
Source§fn change_source(&self) -> ChangeSource
fn change_source(&self) -> ChangeSource
Static when no
planning-variable change can alter them. Macro-generated solution source
methods attach it through hidden internal support.