pub struct LineStreamHandler { /* private fields */ }Expand description
Streaming per-line output handler: prints each completed output line as soon as it arrives instead of buffering everything until command exit.
Ports the upstream line-buffering fix (ClusterShell commits 65e5433 /
GH#528/GH#597): in Python, Display reconfigures sys.stdout /
sys.stderr with line_buffering=True so that piped consumers observe
lines in real time. Rust’s io::Stdout is already a LineWriter, and
this handler additionally flushes after every completed line, giving the
same observable behavior: lines arrive as they are produced, not in one
block at process exit.
Partial lines are buffered per node and flushed on on_close, so no
output is lost even when a node’s final line lacks a trailing newline.
Lines print to stdout with the usual node: label unless disabled.
Note: the core ExecWorker currently reports raw pipe fds in on_read
(never normalized to 1/2), so stderr chunks cannot be told apart from
stdout here — consistent with TaskGatheringHandler, which also folds
them into the stdout buffers. Once the core normalizes fds, a fd == 2
branch can route stderr lines to stderr like Python’s print_line_error.
An optional inner handler (e.g. ProgressHandler) is chained after
every callback.
Implementations§
Source§impl LineStreamHandler
impl LineStreamHandler
Sourcepub fn with_inner(self, inner: Box<dyn EventHandler>) -> Self
pub fn with_inner(self, inner: Box<dyn EventHandler>) -> Self
Chain another handler (called after this one on every event).
Trait Implementations§
Source§impl EventHandler for LineStreamHandler
impl EventHandler for LineStreamHandler
Source§fn on_read(&mut self, node: &str, fd: RawFd, msg: &[u8])
fn on_read(&mut self, node: &str, fd: RawFd, msg: &[u8])
Source§fn on_timeout(&mut self, node: &str)
fn on_timeout(&mut self, node: &str)
Source§fn on_error(&mut self, node: &str, error: &WorkerError)
fn on_error(&mut self, node: &str, error: &WorkerError)
Source§fn take_buffers(
&mut self,
) -> (HashMap<String, Vec<Vec<u8>>>, HashMap<String, Vec<Vec<u8>>>, HashSet<String>)
fn take_buffers( &mut self, ) -> (HashMap<String, Vec<Vec<u8>>>, HashMap<String, Vec<Vec<u8>>>, HashSet<String>)
Vec<chunks>.
Default returns empty maps. Used by Task to collect results after execution.