pub struct AnyJoinInput { /* private fields */ }Expand description
The type-erased aggregated view of branches that have reached a join node.
Use this for joins that intentionally collect mixed branch payload types. Homogeneous joins
should prefer JoinInput<T>, which is checked when transitions are registered.
Implementations§
Source§impl AnyJoinInput
impl AnyJoinInput
Sourcepub fn iter_any(&self) -> impl Iterator<Item = &(dyn Any + Send + Sync)>
pub fn iter_any(&self) -> impl Iterator<Item = &(dyn Any + Send + Sync)>
Iterates over every type-erased branch payload in stable branch creation order.
Sourcepub fn iter<T: NodeArg>(&self) -> impl Iterator<Item = &T>
pub fn iter<T: NodeArg>(&self) -> impl Iterator<Item = &T>
Iterates over every ready branch payload that can be downcast to T.
Values are yielded in stable branch creation order. This is the usual way to read join payloads from a mixed join when you only need one payload type.
§Examples
use swiftide_tasks::{AnyJoinInput, NodeError, Task, Transition};
let mut task = Task::<i32, i32>::new();
let start = task.register_node_fn(|input: &i32| -> Result<i32, NodeError> { Ok(*input) });
let left = task.register_node_fn(|input: &i32| -> Result<i32, NodeError> { Ok(*input + 1) });
let right = task.register_node_fn(|input: &i32| -> Result<i32, NodeError> { Ok(*input + 2) });
let join = task.register_node_fn(|input: &AnyJoinInput| -> Result<i32, NodeError> {
Ok(input.iter::<i32>().copied().sum())
});
task.starts_with(start);
task.register_transition(start, move |value| {
Transition::fan_out(&left, value)
.and(&right, value)
.join_with(join.join_any())
})?;
task.register_transition(left, join.join_any())?;
task.register_transition(right, join.join_any())?;Trait Implementations§
Source§impl Clone for AnyJoinInput
impl Clone for AnyJoinInput
Auto Trait Implementations§
impl !RefUnwindSafe for AnyJoinInput
impl !UnwindSafe for AnyJoinInput
impl Forget for AnyJoinInput
impl Freeze for AnyJoinInput
impl Send for AnyJoinInput
impl Sync for AnyJoinInput
impl Unpin for AnyJoinInput
impl UnsafeUnpin for AnyJoinInput
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more