pub struct Writer { /* private fields */ }
Expand description
A synchronous writer that implements Write
.
This struct allows writing data synchronously, which can be read from a corresponding Reader
.
Multiple Writer
instances can be created by cloning, allowing writes from different threads.
§Notes
- All write calls are executed immediately without blocking the thread.
- It’s safe to use this writer inside async operations.
- Write method will return an error when the reader is dropped.
§Example
use std::io::Write;
use io_pipe::pipe;
let (mut writer, reader) = pipe();
writer.write_all("hello".as_bytes()).unwrap();
Trait Implementations§
Source§impl Write for Writer
impl Write for Writer
Source§fn write(&mut self, buf: &[u8]) -> IOResult<usize>
fn write(&mut self, buf: &[u8]) -> IOResult<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> IOResult<()>
fn flush(&mut self) -> IOResult<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn write_all(&mut self, buf: &[u8]) -> IOResult<()>
fn write_all(&mut self, buf: &[u8]) -> IOResult<()>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_fmt(&mut self, fmt: Arguments<'_>) -> IOResult<()>
fn write_fmt(&mut self, fmt: Arguments<'_>) -> IOResult<()>
Writes a formatted string into this writer, returning any error
encountered. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)Auto Trait Implementations§
impl Freeze for Writer
impl RefUnwindSafe for Writer
impl Send for Writer
impl Sync for Writer
impl Unpin for Writer
impl UnwindSafe for Writer
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