pub struct DrainState<F>{ /* private fields */ }Expand description
Orchestrates non-blocking process I/O.
DrainState tracks the state of stdin, stdout, and stderr pipes for a
single process. It handles the multiplexing of data between these pipes
and internal buffers.
§Example
while !drain.is_done() {
let mut events = Vec::new();
reactor.wait(&mut events, 64, -1)?;
for ev in events {
// Map event tokens to drain calls...
}
}Implementations§
Source§impl<F> DrainState<F>
impl<F> DrainState<F>
Sourcepub fn new(
stdin_fd: Option<Fd>,
stdin_buf: Option<Box<[u8]>>,
stdout_fd: Option<Fd>,
stderr_fd: Option<Fd>,
limit: usize,
early_exit: Option<F>,
) -> Result<Self, CoreError>
pub fn new( stdin_fd: Option<Fd>, stdin_buf: Option<Box<[u8]>>, stdout_fd: Option<Fd>, stderr_fd: Option<Fd>, limit: usize, early_exit: Option<F>, ) -> Result<Self, CoreError>
Initialize a new drain state for the provided descriptors.
This consumes the descriptors and sets them to non-blocking mode.
Sourcepub fn write_stdin(&mut self) -> Result<bool, CoreError>
pub fn write_stdin(&mut self) -> Result<bool, CoreError>
Perform a non-blocking write to stdin if pending.
Sourcepub fn read_fd(&mut self, is_stdout: bool) -> Result<bool, CoreError>
pub fn read_fd(&mut self, is_stdout: bool) -> Result<bool, CoreError>
Perform a non-blocking read from stdout or stderr.
Sourcepub fn into_parts(self) -> (Vec<u8>, Vec<u8>)
pub fn into_parts(self) -> (Vec<u8>, Vec<u8>)
Consume the state and return (stdout, stderr) buffers.
Sourcepub fn output_limit_exceeded(&self) -> bool
pub fn output_limit_exceeded(&self) -> bool
Return whether the combined stdout+stderr output limit was exceeded.
Sourcepub fn stdout_early_exited(&self) -> bool
pub fn stdout_early_exited(&self) -> bool
Return whether stdout was explicitly stopped by the early-exit predicate.
Auto Trait Implementations§
impl<F> Freeze for DrainState<F>where
F: Freeze,
impl<F> RefUnwindSafe for DrainState<F>where
F: RefUnwindSafe,
impl<F> Send for DrainState<F>where
F: Send,
impl<F> Sync for DrainState<F>where
F: Sync,
impl<F> Unpin for DrainState<F>where
F: Unpin,
impl<F> UnsafeUnpin for DrainState<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for DrainState<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more