pub struct Task<Input: NodeArg, Output: NodeArg> { /* private fields */ }
Implementations§
Source§impl<Input: NodeArg + Clone, Output: NodeArg + Clone> Task<Input, Output>
impl<Input: NodeArg + Clone, Output: NodeArg + Clone> Task<Input, Output>
pub fn new() -> Self
pub fn done(&self) -> NodeId<NoopNode<Output>>
Sourcepub fn transitions_to_done(
&self,
) -> impl Fn(Output) -> MarkedTransitionPayload<NoopNode<Output>> + Send + Sync + 'static
pub fn transitions_to_done( &self, ) -> impl Fn(Output) -> MarkedTransitionPayload<NoopNode<Output>> + Send + Sync + 'static
Creates a transition to the done node
Sourcepub fn starts_with<T: TaskNode<Input = Input> + Clone + 'static>(
&mut self,
node_id: NodeId<T>,
)
pub fn starts_with<T: TaskNode<Input = Input> + Clone + 'static>( &mut self, node_id: NodeId<T>, )
Defines the start node of the task
Sourcepub fn validate_transitions(&self) -> Result<(), TaskError>
pub fn validate_transitions(&self) -> Result<(), TaskError>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets the task to the start node
WARN: This will lead to a type mismatch if the previous context is not the same as the input of the start node
Sourcepub fn current_node<T: TaskNode + 'static>(&self) -> Option<&T>
pub fn current_node<T: TaskNode + 'static>(&self) -> Option<&T>
Gets the current node of the task
Sourcepub fn node_at<T: TaskNode + 'static>(&self, node_id: NodeId<T>) -> Option<&T>
pub fn node_at<T: TaskNode + 'static>(&self, node_id: NodeId<T>) -> Option<&T>
Gets the node at the given NodeId
Sourcepub fn node_at_index<T: TaskNode + 'static>(&self, index: usize) -> Option<&T>
pub fn node_at_index<T: TaskNode + 'static>(&self, index: usize) -> Option<&T>
Gets the node at the given index
Sourcepub fn register_node<T>(&mut self, node: T) -> NodeId<T>
pub fn register_node<T>(&mut self, node: T) -> NodeId<T>
Registers a new node in the task
Sourcepub fn register_transition<'a, From, To, F>(
&mut self,
from: NodeId<From>,
transition: F,
) -> Result<(), TaskError>
pub fn register_transition<'a, From, To, F>( &mut self, from: NodeId<From>, transition: F, ) -> Result<(), TaskError>
Registers a transition from one node to another
Note that there are various helpers and conversions for the MarkedTransitionPayload
§Errors
Errors if the node does not exist
Sourcepub fn register_transition_async<'a, From, To, F>(
&mut self,
from: NodeId<From>,
transition: F,
) -> Result<(), TaskError>
pub fn register_transition_async<'a, From, To, F>( &mut self, from: NodeId<From>, transition: F, ) -> Result<(), TaskError>
Registers a transition from one node to another asynchronously
Note that there are various helpers and conversions for the MarkedTransitionPayload
§Errors
Errors if the node does not exist
NOTE: AsyncFn
traits’ returned future are not ‘Send’ and the inner type is unstable.
When they are, we can update Fn to AsyncFn
Trait Implementations§
Auto Trait Implementations§
impl<Input, Output> Freeze for Task<Input, Output>
impl<Input, Output> !RefUnwindSafe for Task<Input, Output>
impl<Input, Output> Send for Task<Input, Output>
impl<Input, Output> Sync for Task<Input, Output>
impl<Input, Output> Unpin for Task<Input, Output>
impl<Input, Output> !UnwindSafe for Task<Input, Output>
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
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>
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>
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