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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// This is free and unencumbered software released into the public domain.
//! Destinations and capture policies for a child process's standard output.
//!
//! The content-specific aliases all refer to [`Output`]; they describe expected
//! payloads without parsing or validating them. [`NoOutput`] represents a program
//! pattern with no output value, rather than a request to discard a stream.
//!
//! # Inherited graph output and error handling
//!
//! `GraphOutput::Inherited` normally connects the child's stdout directly to the
//! parent's stdout, including any redirection or pipe attached to it. The runner
//! does not capture, decode, or batch those bytes. Output `BatchOptions` therefore
//! have no effect on inherited stdout, and do not control the child's own buffering.
//! Program format options (such as `FetcherOptions::output`) still select the
//! serialization. For graph consumers, batching of their input remains applicable.
//!
//! Graph-producing wrappers still return a stream. With inherited stdout, it
//! yields no successful payload batches: it ends on successful completion or
//! yields an error. **Consume that stream to completion**, even though stdout is
//! already visible. Polling drives stdin feeding, captured stderr draining, and
//! process waiting. The outer `execute().await?` handles startup errors; the
//! inner `result?` handles later input, I/O, and exit failures. Dropping the stream
//! immediately after spawning instead requests child termination. Output already
//! written to stdout cannot be withdrawn if the child subsequently fails.
//! Since the runner does not perform directly inherited stdout writes, failures
//! of those writes must be reported by the child, typically through its exit status.
//!
//! ```no_run
//! # #[cfg(feature = "std")]
//! #[tokio::main(flavor = "current_thread")]
//! async fn main() -> Result<(), asimov_runner::ExecutorError> {
//! use asimov_runner::{Fetcher, FetcherOptions, GraphOutput, StreamExt};
//!
//! let mut fetcher = Fetcher::new(
//! "asimov-example-fetcher",
//! "https://example.com/resource",
//! GraphOutput::Inherited,
//! FetcherOptions::builder().output("jsonl").build(),
//! );
//!
//! let mut execution = fetcher.execute().await?;
//! while let Some(result) = execution.next().await {
//! result?; // Propagate failures; there are no captured batches to print.
//! }
//! Ok(()) // Completion, not merely successful spawning, has been checked.
//! }
//! # #[cfg(not(feature = "std"))]
//! # fn main() {}
//! ```
//!
//! The same consumption loop applies to a graph-producing pipeline with an
//! inherited-output tail; its stream reports `PipelineError` and checks all stages.
//! A limited `Lister` is the routing exception: it pipes, counts, and forwards
//! stdout to the parent so the local line cap cannot be bypassed. It still emits
//! no payload batches, and polling is required to perform that forwarding. Reaching
//! the cap deliberately stops the child without checking its eventual exit status;
//! a zero limit starts no child. See the [lister execution contract][lister].
//!
//! [lister]: https://docs.rs/asimov-runner/latest/asimov_runner/struct.Lister.html#method.execute
use Box;
use Debug;
use AsyncWrite;
/// An output stream with no prescribed content type.
pub type AnyOutput = Output;
/// Stdout handling for a graph producer, whose captured output is a JSONL batch stream.
pub type GraphOutput = Output;
/// The absence of an output value for a program pattern.
pub type NoOutput = ;
/// An output stream intended to contain a SPARQL query, such as a compiler's result.
pub type QueryOutput = Output;
/// An output stream intended to contain text, without enforcing an encoding.
pub type TextOutput = Output;
/// How a child's stdout should be connected or collected.
///
/// Only [`Captured`](Self::Captured) returns payload bytes. Ignored, inherited,
/// and forwarded output produces an empty result payload. Execution still checks
/// input delivery and process success for every mode.
///
/// With `std` enabled, conversion to `Stdio` only configures the stream; it does
/// not copy bytes into a writer. The consuming conversion drops any stored
/// writer, while `Output::as_stdio` preserves it.