Struct io_streams::StreamDuplexer
source · pub struct StreamDuplexer { /* private fields */ }
Expand description
An unbuffered and unlocked interactive combination input and output stream,
implementing Read
and Write
.
This may hold two file descriptors, one for reading and one for writing, such as stdin and stdout, or it may hold one file handle for both reading and writing, such as for a TCP socket.
There is no file
constructor, even though File
implements both Read
and Write
, because normal files are not interactive. However, there is a
char_device
constructor for character device files.
Implementations§
source§impl StreamDuplexer
impl StreamDuplexer
sourcepub fn stdin_stdout() -> Result<Self>
pub fn stdin_stdout() -> Result<Self>
Duplex with stdin and stdout, taking ownership of them.
Unlike std::io::stdin
and std::io::stdout
, this stdin_stdout
returns a stream which is unbuffered and unlocked.
This acquires a std::io::StdinLock
and a std::io::StdoutLock
(in non-recursive ways) to prevent accesses to std::io::Stdin
and
std::io::Stdout
while this is live, and fails if a StreamReader
for standard input, a StreamWriter
for standard output, or a
StreamDuplexer
for standard input and standard output already exist.
sourcepub fn tcp_stream<Socketlike: IntoSocketlike>(socketlike: Socketlike) -> Self
pub fn tcp_stream<Socketlike: IntoSocketlike>(socketlike: Socketlike) -> Self
Duplex with an open TCP stream, taking ownership of it.
This method can be passed a std::net::TcpStream
or similar
TcpStream
types.
sourcepub fn unix_stream(unix_stream: UnixStream) -> Self
pub fn unix_stream(unix_stream: UnixStream) -> Self
Duplex with an open Unix-domain stream, taking ownership of it.
sourcepub fn pipe_reader_writer(
pipe_reader: PipeReader,
pipe_writer: PipeWriter
) -> Self
pub fn pipe_reader_writer( pipe_reader: PipeReader, pipe_writer: PipeWriter ) -> Self
Duplex with a pair of pipe streams, taking ownership of them.
sourcepub fn duplex_with_command(command: Command) -> Result<Self>
pub fn duplex_with_command(command: Command) -> Result<Self>
Spawn the given command and duplex with its standard input and output.
sourcepub fn child_stdout_stdin(
child_stdout: ChildStdout,
child_stdin: ChildStdin
) -> Self
pub fn child_stdout_stdin( child_stdout: ChildStdout, child_stdin: ChildStdin ) -> Self
Duplex with a child process’ stdout and stdin, taking ownership of them.
Trait Implementations§
source§impl AsRawReadWriteFd for StreamDuplexer
impl AsRawReadWriteFd for StreamDuplexer
source§fn as_raw_read_fd(&self) -> RawFd
fn as_raw_read_fd(&self) -> RawFd
source§fn as_raw_write_fd(&self) -> RawFd
fn as_raw_write_fd(&self) -> RawFd
source§impl AsReadWriteFd for StreamDuplexer
impl AsReadWriteFd for StreamDuplexer
source§fn as_read_fd(&self) -> BorrowedFd<'_>
fn as_read_fd(&self) -> BorrowedFd<'_>
source§fn as_write_fd(&self) -> BorrowedFd<'_>
fn as_write_fd(&self) -> BorrowedFd<'_>
source§impl Debug for StreamDuplexer
impl Debug for StreamDuplexer
source§impl Peek for StreamDuplexer
impl Peek for StreamDuplexer
source§impl Read for StreamDuplexer
impl Read for StreamDuplexer
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
buf
. Read moresource§fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize>
buf
. Read moresource§fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moresource§impl ReadReady for StreamDuplexer
impl ReadReady for StreamDuplexer
source§impl Write for StreamDuplexer
impl Write for StreamDuplexer
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 Duplex for StreamDuplexer
Auto Trait Implementations§
impl Freeze for StreamDuplexer
impl !RefUnwindSafe for StreamDuplexer
impl Send for StreamDuplexer
impl Sync for StreamDuplexer
impl Unpin for StreamDuplexer
impl !UnwindSafe for StreamDuplexer
Blanket Implementations§
source§impl<T> AsRawReadWriteGrip for Twhere
T: AsRawReadWriteFd,
impl<T> AsRawReadWriteGrip for Twhere
T: AsRawReadWriteFd,
source§fn as_raw_read_grip(&self) -> i32
fn as_raw_read_grip(&self) -> i32
source§fn as_raw_write_grip(&self) -> i32
fn as_raw_write_grip(&self) -> i32
source§impl<T> AsReadWriteGrip for Twhere
T: AsReadWriteFd,
impl<T> AsReadWriteGrip for Twhere
T: AsReadWriteFd,
source§fn as_read_grip(&self) -> BorrowedFd<'_>
fn as_read_grip(&self) -> BorrowedFd<'_>
source§fn as_write_grip(&self) -> BorrowedFd<'_>
fn as_write_grip(&self) -> BorrowedFd<'_>
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,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
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