pub struct StreamWriter { /* private fields */ }Expand description
An unbuffered and unlocked output byte stream, implementing Write,
abstracted over the destination of the output.
It primarily consists of a single file handle, and also contains any resources needed to safely hold the file handle live.
Since it is unbuffered, and since many destinations have high per-call
overhead, it is often beneficial to wrap this in a BufWriter or
LineWriter.
Implementations§
Source§impl StreamWriter
impl StreamWriter
Sourcepub fn stdout() -> Result<Self>
pub fn stdout() -> Result<Self>
Write to standard output.
Unlike std::io::stdout, this stdout returns a stream which is
unbuffered and unlocked.
Since it is unbuffered, it is often beneficial to wrap the resulting
StreamWriter in a BufWriter or LineWriter.
This acquires a std::io::StdoutLock (in a non-recursive way) to
prevent accesses to std::io::Stdout while this is live, and fails if
a StreamWriter or StreamDuplexer for standard output already
exists.
Sourcepub fn stderr() -> Result<Self>
pub fn stderr() -> Result<Self>
Write to standard error.
Like std::io::stderr, this stderr returns a stream which is
unbuffered. However, unlike std::io::stderr, the stream is also
unlocked.
Since it is unbuffered, it is often beneficial to wrap the resulting
StreamWriter in a BufWriter or LineWriter.
This acquires a std::io::StderrLock (in a non-recursive way) to
prevent accesses to std::io::Stderr while this is live, and fails if
a StreamWriter or StreamDuplexer for standard output already
exists.
Sourcepub fn file<Filelike: IntoFilelike + Read + Write + Seek>(
filelike: Filelike,
) -> Self
pub fn file<Filelike: IntoFilelike + Read + Write + Seek>( filelike: Filelike, ) -> Self
Write to an open file, taking ownership of it.
This method can be passed a std::fs::File or similar File types.
Sourcepub fn tcp_stream<Socketlike: IntoSocketlike>(socketlike: Socketlike) -> Self
pub fn tcp_stream<Socketlike: IntoSocketlike>(socketlike: Socketlike) -> Self
Write to an open TCP stream, taking ownership of it.
This method can be passed a std::net::TcpStream or similar
TcpStream types.
Sourcepub fn pipe_writer(pipe_writer: PipeWriter) -> Self
pub fn pipe_writer(pipe_writer: PipeWriter) -> Self
Write to the writing end of an open pipe, taking ownership of it.
Sourcepub fn write_to_command(command: Command) -> Result<Self>
pub fn write_to_command(command: Command) -> Result<Self>
Spawn the given command and write to its standard input. Its standard
output is redirected to Stdio::null().
Sourcepub fn child_stdin(child_stdin: ChildStdin) -> Self
pub fn child_stdin(child_stdin: ChildStdin) -> Self
Write to the given child standard input, taking ownership of it.
Sourcepub fn piped_thread(boxed_write: Box<dyn Write + Send>) -> Result<Self>
pub fn piped_thread(boxed_write: Box<dyn Write + Send>) -> Result<Self>
Write to a boxed Write implementation, taking ownership of it. This
works by creating a new thread to read the data through a pipe and
write it.
Writes to the pipe aren’t synchronous with writes to the boxed Write
implementation. To ensure data is flushed all the way through the
thread and into the boxed Write implementation, call flush(),
which synchronizes with the thread to ensure that is has completed
writing all pending output.
Trait Implementations§
Source§impl AsHandleOrSocket for StreamWriter
impl AsHandleOrSocket for StreamWriter
Source§fn as_handle_or_socket(&self) -> BorrowedHandleOrSocket<'_>
fn as_handle_or_socket(&self) -> BorrowedHandleOrSocket<'_>
AsHandle::as_handle and AsSocket::as_socket
but can return either type.Source§impl AsRawHandleOrSocket for StreamWriter
impl AsRawHandleOrSocket for StreamWriter
Source§fn as_raw_handle_or_socket(&self) -> RawHandleOrSocket
fn as_raw_handle_or_socket(&self) -> RawHandleOrSocket
AsRawHandle::as_raw_handle and AsRawSocket::as_raw_socket
but can return either type.Source§impl Debug for StreamWriter
impl Debug for StreamWriter
Source§impl Write for StreamWriter
impl Write for StreamWriter
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)Source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
write_all_vectored)impl Send for StreamWriter
impl Sync for StreamWriter
Auto Trait Implementations§
impl Freeze for StreamWriter
impl !RefUnwindSafe for StreamWriter
impl Unpin for StreamWriter
impl !UnwindSafe for StreamWriter
Blanket Implementations§
Source§impl<T> AsGrip for Twhere
T: AsHandleOrSocket,
impl<T> AsGrip for Twhere
T: AsHandleOrSocket,
Source§fn as_grip(&self) -> BorrowedHandleOrSocket<'_>
fn as_grip(&self) -> BorrowedHandleOrSocket<'_>
Source§impl<T> AsRawGrip for Twhere
T: AsRawHandleOrSocket,
impl<T> AsRawGrip for Twhere
T: AsRawHandleOrSocket,
Source§fn as_raw_grip(&self) -> RawHandleOrSocket
fn as_raw_grip(&self) -> RawHandleOrSocket
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
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike + FromFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike + FromFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read more