Struct layered_io::LayeredDuplexer
source · pub struct LayeredDuplexer<Inner> { /* private fields */ }
Expand description
Adapts an Read
+ Write
to implement HalfDuplexLayered
.
Implementations
sourceimpl<Inner: Read + Write> LayeredDuplexer<Inner>
impl<Inner: Read + Write> LayeredDuplexer<Inner>
sourcepub fn new(inner: Inner) -> Self
pub fn new(inner: Inner) -> Self
Construct a new LayeredDuplexer
which wraps inner
with default
settings.
sourcepub fn with_eos_as_push(inner: Inner) -> Self
pub fn with_eos_as_push(inner: Inner) -> Self
Construct a new LayeredDuplexer
which wraps inner
. When inner
reports end of stream (by returning 0), report a push but keep the
stream open and continue to read data on it.
For example, when reading a file, when the reader reaches the end of the file it will report it, but consumers may wish to continue reading in case additional data is appended to the file.
sourcepub fn line_by_line(inner: Inner) -> Self
pub fn line_by_line(inner: Inner) -> Self
Construct a new LayeredDuplexer
which wraps an inner
which reads
its input line-by-line, such as stdin on a terminal.
sourcepub fn close_into_inner(self) -> Result<Inner>
pub fn close_into_inner(self) -> Result<Inner>
Close this LayeredDuplexer
and return the inner stream.
sourcepub fn abandon_into_inner(self) -> Option<Inner>
pub fn abandon_into_inner(self) -> Option<Inner>
Consume this LayeredDuplexer
and return the inner stream.
Trait Implementations
sourceimpl<Inner: Duplex + AsRawReadWriteFd> AsRawReadWriteFd for LayeredDuplexer<Inner>
impl<Inner: Duplex + AsRawReadWriteFd> AsRawReadWriteFd for LayeredDuplexer<Inner>
sourcefn as_raw_read_fd(&self) -> RawFd
fn as_raw_read_fd(&self) -> RawFd
Extracts the raw file descriptor for reading. Read more
sourcefn as_raw_write_fd(&self) -> RawFd
fn as_raw_write_fd(&self) -> RawFd
Extracts the raw file descriptor for writing. Read more
sourceimpl<Inner: Duplex + AsReadWriteFd> AsReadWriteFd for LayeredDuplexer<Inner>
impl<Inner: Duplex + AsReadWriteFd> AsReadWriteFd for LayeredDuplexer<Inner>
sourcefn as_read_fd(&self) -> BorrowedFd<'_>
fn as_read_fd(&self) -> BorrowedFd<'_>
Extracts the file descriptor for reading. Read more
sourcefn as_write_fd(&self) -> BorrowedFd<'_>
fn as_write_fd(&self) -> BorrowedFd<'_>
Extracts the file descriptor for writing. Read more
sourceimpl<Inner> Bufferable for LayeredDuplexer<Inner>
impl<Inner> Bufferable for LayeredDuplexer<Inner>
sourcefn suggested_buffer_size(&self) -> usize
fn suggested_buffer_size(&self) -> usize
A suggested size, in bytes, for buffering for performance.
sourceimpl<Inner: Debug> Debug for LayeredDuplexer<Inner>
impl<Inner: Debug> Debug for LayeredDuplexer<Inner>
sourceimpl<Inner> Drop for LayeredDuplexer<Inner>
impl<Inner> Drop for LayeredDuplexer<Inner>
sourceimpl<Inner: Read + Write> Read for LayeredDuplexer<Inner>
impl<Inner: Read + Write> Read for LayeredDuplexer<Inner>
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
sourcefn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
Like
read
, except that it reads into a slice of buffers. Read moresourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)sourcefn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
Read all bytes until EOF in this source, placing them into
buf
. Read moresourcefn read_to_string(&mut self, buf: &mut String) -> Result<usize>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
Read all bytes until EOF in this source, appending them to
buf
. Read moresourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
Read the exact number of bytes required to fill
buf
. Read moresourcefn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Pull some bytes from this source into the specified buffer. Read more
sourcefn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf
)Read the exact number of bytes required to fill
cursor
. Read more1.0.0 · sourcefn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adaptor for this instance of
Read
. Read moresourceimpl<Inner: Read + Write> ReadLayered for LayeredDuplexer<Inner>
impl<Inner: Read + Write> ReadLayered for LayeredDuplexer<Inner>
sourcefn read_with_status(&mut self, buf: &mut [u8]) -> Result<(usize, Status)>
fn read_with_status(&mut self, buf: &mut [u8]) -> Result<(usize, Status)>
Like
Read::read
, but also returns a Status
.sourcefn read_vectored_with_status(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<(usize, Status)>
fn read_vectored_with_status(
&mut self,
bufs: &mut [IoSliceMut<'_>]
) -> Result<(usize, Status)>
Like
Read::read_vectored
, but also returns a Status
.sourcefn read_exact_using_status(&mut self, buf: &mut [u8]) -> Result<Status>
fn read_exact_using_status(&mut self, buf: &mut [u8]) -> Result<Status>
Like
Read::read_exact
, but uses read_with_status
to avoid
performing an extra read
at the end. Read moresourcefn minimum_buffer_size(&self) -> usize
fn minimum_buffer_size(&self) -> usize
Some streams require a buffer of at least a certain size.
sourceimpl<Inner: Read + Write> Write for LayeredDuplexer<Inner>
impl<Inner: Read + Write> Write for LayeredDuplexer<Inner>
sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this writer, returning how many bytes were written. Read more
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
sourcefn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize>
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)sourcefn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
Attempts to write an entire buffer into this writer. Read more
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<()>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
sourceimpl<Inner: Read + Write> WriteLayered for LayeredDuplexer<Inner>
impl<Inner: Read + Write> WriteLayered for LayeredDuplexer<Inner>
impl<Inner: Read + Write + Duplex> Duplex for LayeredDuplexer<Inner>
Auto Trait Implementations
impl<Inner> RefUnwindSafe for LayeredDuplexer<Inner>where
Inner: RefUnwindSafe,
impl<Inner> Send for LayeredDuplexer<Inner>where
Inner: Send,
impl<Inner> Sync for LayeredDuplexer<Inner>where
Inner: Sync,
impl<Inner> Unpin for LayeredDuplexer<Inner>where
Inner: Unpin,
impl<Inner> UnwindSafe for LayeredDuplexer<Inner>where
Inner: UnwindSafe,
Blanket Implementations
sourceimpl<T> AsRawReadWriteGrip for Twhere
T: AsRawReadWriteFd,
impl<T> AsRawReadWriteGrip for Twhere
T: AsRawReadWriteFd,
sourcefn as_raw_read_grip(&self) -> i32
fn as_raw_read_grip(&self) -> i32
Extracts the grip for reading. Read more
sourcefn as_raw_write_grip(&self) -> i32
fn as_raw_write_grip(&self) -> i32
Extracts the grip for writing. Read more
sourceimpl<T> AsReadWriteGrip for Twhere
T: AsReadWriteFd,
impl<T> AsReadWriteGrip for Twhere
T: AsReadWriteFd,
sourcefn as_read_grip(&self) -> BorrowedFd<'_>
fn as_read_grip(&self) -> BorrowedFd<'_>
Extracts the grip for reading. Read more
sourcefn as_write_grip(&self) -> BorrowedFd<'_>
fn as_write_grip(&self) -> BorrowedFd<'_>
Extracts the grip for writing. Read more
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more