1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! Error handling strategies for pipeline operations
/// Trait for custom error handling strategies
///
/// This trait defines how different error handling strategies should process
/// a collection of results. Implementors can define custom logic for handling
/// errors in different ways.
///
/// # Examples
///
/// ```rust
/// use pipex::ErrorHandler;
///
/// struct MyCustomHandler;
///
/// impl<T, E> ErrorHandler<T, E> for MyCustomHandler {
/// fn handle_results(results: Vec<Result<T, E>>) -> Vec<Result<T, E>> {
/// // Custom logic here
/// results
/// }
/// }
/// ```
/// Ignore errors strategy
///
/// This strategy filters out all error results, returning only the successful ones.
/// This is useful when you want to continue processing despite some failures.
///
/// # Examples
///
/// ```rust
/// use pipex::{ErrorHandler, IgnoreHandler};
///
/// let results = vec![Ok(1), Err("error"), Ok(3)];
/// let handled = IgnoreHandler::handle_results(results);
/// assert_eq!(handled, vec![Ok(1), Ok(3)]);
/// ```
;
/// Collect all strategy
///
/// This strategy returns all results as-is, both successful and error results.
/// This is the default behavior when no specific error handling is needed.
///
/// # Examples
///
/// ```rust
/// use pipex::{ErrorHandler, CollectHandler};
///
/// let results = vec![Ok(1), Err("error"), Ok(3)];
/// let handled = CollectHandler::handle_results(results);
/// assert_eq!(handled, vec![Ok(1), Err("error"), Ok(3)]);
/// ```
;
/// Fail fast strategy
///
/// This strategy returns only the error results, filtering out all successful ones.
/// This is useful when you want to focus on handling errors and stopping
/// processing on the first error encountered.
///
/// # Examples
///
/// ```rust
/// use pipex::{ErrorHandler, FailFastHandler};
///
/// let results = vec![Ok(1), Err("error"), Ok(3)];
/// let handled = FailFastHandler::handle_results(results);
/// assert_eq!(handled, vec![Err("error")]);
/// ```
;
/// Log and ignore errors strategy
///
/// This strategy logs all errors to stderr and then filters them out,
/// returning only the successful results. This combines error visibility
/// with continued processing.
///
/// # Examples
///
/// ```rust
/// use pipex::{ErrorHandler, LogAndIgnoreHandler};
///
/// let results = vec![Ok(1), Err("error"), Ok(3)];
/// let handled = LogAndIgnoreHandler::handle_results(results);
/// // This will print "Pipeline error (ignored): error" to stderr
/// assert_eq!(handled, vec![Ok(1), Ok(3)]);
/// ```
;