pub struct JoinTarget<T: TaskNode<Input = JoinInput<Payload>> + ?Sized, Payload: NodeArg> { /* private fields */ }Expand description
A configured join destination for branches that should converge into a join node.
Build a JoinTarget from a join node with NodeId::join,
and then register it through
Task::register_transition.
Users normally do not construct this type directly.
Implementations§
Source§impl<T, Payload> JoinTarget<T, Payload>
impl<T, Payload> JoinTarget<T, Payload>
Sourcepub fn map<F>(self, map: F) -> MappedJoinTarget<T, Payload, F>
pub fn map<F>(self, map: F) -> MappedJoinTarget<T, Payload, F>
Maps each joining branch output into the payload stored for the join node.
§Examples
use swiftide_tasks::{JoinInput, NodeError, Task, Transition};
let mut task = Task::<i32, i32>::new();
let start = task.register_node_fn(|input: &i32| -> Result<i32, NodeError> { Ok(*input) });
let branch = task.register_node_fn(|input: &i32| -> Result<i32, NodeError> { Ok(*input + 1) });
let join = task.register_node_fn(|input: &JoinInput<i32>| -> Result<i32, NodeError> {
Ok(input.iter().copied().sum())
});
task.starts_with(start);
task.register_transition(start, move |value| {
Transition::fan_out(&branch, value)
.join_with(join.join())
})?;
task.register_transition(branch, join.join().map(|value| value * 2))?;Sourcepub fn map_async<F>(self, map: F) -> MappedJoinTarget<T, Payload, F>
pub fn map_async<F>(self, map: F) -> MappedJoinTarget<T, Payload, F>
Maps each joining branch output asynchronously before storing it for the join node.
§Examples
use swiftide_tasks::{JoinInput, NodeError, Task, Transition};
let mut task = Task::<i32, i32>::new();
let start = task.register_node_fn(|input: &i32| -> Result<i32, NodeError> { Ok(*input) });
let branch = task.register_node_fn(|input: &i32| -> Result<i32, NodeError> { Ok(*input + 1) });
let join = task.register_node_fn(|input: &JoinInput<i32>| -> Result<i32, NodeError> {
Ok(input.iter().copied().sum())
});
task.starts_with(start);
task.register_transition(start, move |value| {
Transition::fan_out(&branch, value)
.join_with(join.join())
})?;
task.register_transition_async(branch, join.join().map_async(|value| async move { value * 2 }))?;Auto Trait Implementations§
impl<T, Payload> !Send for JoinTarget<T, Payload>
impl<T, Payload> !Sync for JoinTarget<T, Payload>
impl<T, Payload> Forget for JoinTarget<T, Payload>where
T: ?Sized,
impl<T, Payload> Freeze for JoinTarget<T, Payload>
impl<T, Payload> RefUnwindSafe for JoinTarget<T, Payload>
impl<T, Payload> Unpin for JoinTarget<T, Payload>
impl<T, Payload> UnsafeUnpin for JoinTarget<T, Payload>
impl<T, Payload> UnwindSafe for JoinTarget<T, Payload>
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> 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