NodeOutput

Enum NodeOutput 

Source
pub enum NodeOutput<T> {
    SoftFail,
    Ok(T),
}
Expand description

Represents the outcome of a node execution, with support for soft failures.

§Examples

use node_flow::node::NodeOutput;

let success: NodeOutput<i32> = NodeOutput::Ok(42);
let failure: NodeOutput<i32> = NodeOutput::SoftFail;

assert_eq!(success.ok(), Some(42));
assert_eq!(failure.ok(), None);

Variants§

§

SoftFail

Indicates that the node failed in a non-critical way and produced no output.

This is distinct from a hard failure (error) and may simply mean that input conditions were not met.

§

Ok(T)

Indicates that the node successfully produced a value of type T.

Implementations§

Source§

impl<T> NodeOutput<T>

Source

pub fn ok(self) -> Option<T>

Converts NodeOutput<T> into an Option<T>.

§Examples
use node_flow::node::NodeOutput;

let output = NodeOutput::Ok(5);
assert_eq!(output.ok(), Some(5));

let failed = NodeOutput::<i32>::SoftFail;
assert_eq!(failed.ok(), None);
Source

pub fn ok_or<E>(self, err: E) -> Result<T, E>

Converts NodeOutput<T> into a Result<T, E>, using a provided error value if soft-failed.

§Errors

Returns the provided err value if the node soft-failed.

§Examples
use node_flow::node::NodeOutput;

let ok: Result<i32, &str> = NodeOutput::Ok(42).ok_or("no value");
assert_eq!(ok, Ok(42));

let soft_fail: Result<i32, &str> = NodeOutput::SoftFail.ok_or("no value");
assert_eq!(soft_fail, Err("no value"));
Source

pub fn ok_or_else<E>(self, err: impl Fn() -> E) -> Result<T, E>

Converts NodeOutput<T> into a Result<T, E>, lazily computing the error value if soft-failed.

This is the lazy variant of NodeOutput::ok_or, avoiding unnecessary error construction when the node succeeds.

§Errors

Calls the provided closure to produce an error if the node soft-failed.

§Examples
use node_flow::node::NodeOutput;

let ok: Result<i32, String> = NodeOutput::Ok(10).ok_or_else(|| "soft fail".to_string());
assert_eq!(ok, Ok(10));

let soft_fail: Result<i32, String> = NodeOutput::SoftFail.ok_or_else(|| "soft fail".to_string());
assert_eq!(soft_fail, Err("soft fail".to_string()));

Trait Implementations§

Source§

impl<T: Debug> Debug for NodeOutput<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Input, Error, Context, NodeType, NodeOutput, NodeError> Node<Input, NodeOutput<Input>, Error, Context> for Detached<Input, Error, Context, NodeType, NodeOutput, NodeError>
where NodeType: Node<Input, NodeOutput, NodeError, Context> + Clone + Send + 'static, Context: SpawnAsync + Fork + Send + 'static, Input: Clone + Send + 'static,

Source§

fn run( &mut self, input: Input, context: &mut Context, ) -> impl Future<Output = Result<NodeOutput<Input>, Error>> + Send

Runs the node. Read more
Source§

fn describe(&self) -> Description

Describes this node, its type signature and other specifics. Read more
Source§

impl<Input, Output, Error, Context, InnerData, R> Node<Input, NodeOutput<Output>, Error, Context> for FnFlow<Input, Output, Error, Context, InnerData, R>
where InnerData: Clone, for<'a> R: Runner<'a, Input, Output, Error, Context, InnerData>,

Source§

fn run( &mut self, input: Input, context: &mut Context, ) -> impl Future<Output = Result<NodeOutput<Output>, Error>> + Send

Runs the node. Read more
Source§

fn describe(&self) -> Description

Describes this node, its type signature and other specifics. Read more
Source§

impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> Node<Input, NodeOutput<Output>, Error, Context> for OneOfParallelFlow<Input, Output, Error, Context, NodeTypes, NodeIOETypes>
where NodeTypes: ChainRun<Input, Result<NodeOutput<Output>, Error>, Context, NodeIOETypes> + ChainDescribe<Context, NodeIOETypes>,

Source§

fn run( &mut self, input: Input, context: &mut Context, ) -> impl Future<Output = Result<NodeOutput<Output>, Error>> + Send

Runs the node. Read more
Source§

fn describe(&self) -> Description

Describes this node, its type signature and other specifics. Read more
Source§

impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> Node<Input, NodeOutput<Output>, Error, Context> for OneOfSequentialFlow<Input, Output, Error, Context, NodeTypes, NodeIOETypes>
where NodeTypes: ChainRun<Input, Result<NodeOutput<Output>, Error>, Context, NodeIOETypes> + ChainDescribe<Context, NodeIOETypes>,

Source§

fn run( &mut self, input: Input, context: &mut Context, ) -> impl Future<Output = Result<NodeOutput<Output>, Error>> + Send

Runs the node. Read more
Source§

fn describe(&self) -> Description

Describes this node, its type signature and other specifics. Read more
Source§

impl<Input, Output, Error, Context, ChainRunOutput, J, NodeTypes, NodeIOETypes> Node<Input, NodeOutput<Output>, Error, Context> for ParallelFlow<Input, Output, Error, Context, ChainRunOutput, J, NodeTypes, NodeIOETypes>
where Input: Send, Context: Send, for<'a> J: Joiner<'a, ChainRunOutput, Output, Error, Context>, NodeTypes: ChainRun<Input, Result<ChainRunOutput, Error>, Context, NodeIOETypes> + ChainDescribe<Context, NodeIOETypes> + Send + Sync,

Source§

fn run( &mut self, input: Input, context: &mut Context, ) -> impl Future<Output = Result<NodeOutput<Output>, Error>> + Send

Runs the node. Read more
Source§

fn describe(&self) -> Description

Describes this node, its type signature and other specifics. Read more
Source§

impl<Input, Output, Error, Context, NodeTypes, NodeIOETypes> Node<Input, NodeOutput<Output>, Error, Context> for SequentialFlow<Input, Output, Error, Context, NodeTypes, NodeIOETypes>
where NodeTypes: ChainRun<Input, Result<NodeOutput<Output>, Error>, Context, NodeIOETypes> + ChainDescribe<Context, NodeIOETypes>,

Source§

fn run( &mut self, input: Input, context: &mut Context, ) -> impl Future<Output = Result<NodeOutput<Output>, Error>> + Send

Runs the node. Read more
Source§

fn describe(&self) -> Description

Describes this node, its type signature and other specifics. Read more
Source§

impl<T: PartialEq> PartialEq for NodeOutput<T>

Source§

fn eq(&self, other: &NodeOutput<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Eq> Eq for NodeOutput<T>

Source§

impl<T> StructuralPartialEq for NodeOutput<T>

Auto Trait Implementations§

§

impl<T> Freeze for NodeOutput<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for NodeOutput<T>
where T: RefUnwindSafe,

§

impl<T> Send for NodeOutput<T>
where T: Send,

§

impl<T> Sync for NodeOutput<T>
where T: Sync,

§

impl<T> Unpin for NodeOutput<T>
where T: Unpin,

§

impl<T> UnwindSafe for NodeOutput<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V