Skip to content

Commit 00ece52

Browse files
committed
Add helper bounds to OneOfSequentialFlow for better error messages
1 parent 9857c43 commit 00ece52

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

src/flows/one_of_sequential_flow/builder.rs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,31 @@ use crate::{
55
node::{Node, NodeOutput as NodeOutputStruct},
66
};
77

8-
pub struct OneOfSequentialFlowBuilder<Input, Output, Error, NodeTypes = (), NodeIOETypes = ()> {
8+
pub struct OneOfSequentialFlowBuilder<Input, Output, Error, NodeTypes = (), NodeIOETypes = ()>
9+
where
10+
// Trait bounds for better and nicer errors
11+
Input: Send + Clone,
12+
{
913
_ioe: PhantomData<(Input, Output, Error)>,
1014
_nodes_io: PhantomData<NodeIOETypes>,
1115
nodes: NodeTypes,
1216
}
1317

14-
impl<Input, Output, Error> Default for OneOfSequentialFlowBuilder<Input, Output, Error> {
18+
impl<Input, Output, Error> Default for OneOfSequentialFlowBuilder<Input, Output, Error>
19+
where
20+
// Trait bounds for better and nicer errors
21+
Input: Send + Clone,
22+
{
1523
fn default() -> Self {
1624
Self::new()
1725
}
1826
}
1927

20-
impl<Input, Output, Error> OneOfSequentialFlowBuilder<Input, Output, Error> {
28+
impl<Input, Output, Error> OneOfSequentialFlowBuilder<Input, Output, Error>
29+
where
30+
// Trait bounds for better and nicer errors
31+
Input: Send + Clone,
32+
{
2133
#[must_use]
2234
pub fn new() -> Self {
2335
Self {
@@ -42,7 +54,9 @@ impl<Input, Output, Error> OneOfSequentialFlowBuilder<Input, Output, Error> {
4254
Input: Into<NodeInput>,
4355
NodeOutput: Into<Output>,
4456
NodeError: Into<Error>,
45-
NodeType: Node<NodeInput, NodeOutputStruct<NodeOutput>, NodeError> + Clone,
57+
NodeType: Node<NodeInput, NodeOutputStruct<NodeOutput>, NodeError>,
58+
// Trait bounds for better and nicer errors
59+
NodeType: Clone + Send + Sync,
4660
{
4761
OneOfSequentialFlowBuilder {
4862
_ioe: PhantomData,
@@ -60,6 +74,9 @@ impl<Input, Output, Error, NodeTypes, LastNodeIOETypes, OtherNodeIOETypes>
6074
NodeTypes,
6175
ChainLink<OtherNodeIOETypes, LastNodeIOETypes>,
6276
>
77+
where
78+
// Trait bounds for better and nicer errors
79+
Input: Send + Clone,
6380
{
6481
#[allow(clippy::type_complexity)]
6582
pub fn add_node<NodeType, NodeInput, NodeOutput, NodeError>(
@@ -79,7 +96,9 @@ impl<Input, Output, Error, NodeTypes, LastNodeIOETypes, OtherNodeIOETypes>
7996
Input: Into<NodeInput>,
8097
NodeOutput: Into<Output>,
8198
NodeError: Into<Error>,
82-
NodeType: Node<NodeInput, NodeOutputStruct<NodeOutput>, NodeError> + Clone,
99+
NodeType: Node<NodeInput, NodeOutputStruct<NodeOutput>, NodeError>,
100+
// Trait bounds for better and nicer errors
101+
NodeType: Clone + Send + Sync,
83102
{
84103
OneOfSequentialFlowBuilder {
85104
_ioe: PhantomData,

src/flows/one_of_sequential_flow/flow.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ pub struct OneOfSequentialFlow<Input, Output, Error, NodeTypes = (), NodeIOEType
1414
pub(super) nodes: Arc<NodeTypes>,
1515
}
1616

17-
impl<Input, Output, Error> OneOfSequentialFlow<Input, Output, Error> {
17+
impl<Input, Output, Error> OneOfSequentialFlow<Input, Output, Error>
18+
where
19+
// Trait bounds for better and nicer errors
20+
Input: Send + Clone,
21+
{
1822
#[must_use]
1923
pub fn builder() -> OneOfSequentialFlowBuilder<Input, Output, Error> {
2024
OneOfSequentialFlowBuilder::new()
@@ -25,6 +29,8 @@ impl<Input, Output, Error, NodeTypes, NodeIOETypes> Node<Input, NodeOutputStruct
2529
for OneOfSequentialFlow<Input, Output, Error, NodeTypes, NodeIOETypes>
2630
where
2731
NodeTypes: ChainRunOneOfSequential<Input, NodeResult<Output, Error>, NodeIOETypes>,
32+
// Trait bounds for better and nicer errors
33+
Input: Send + Clone,
2834
{
2935
fn run_with_storage(
3036
&mut self,

0 commit comments

Comments
 (0)