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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)