Struct io_streams::StreamDuplexer[][src]

pub struct StreamDuplexer { /* fields omitted */ }
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

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.

This is supported on crate feature char-device only.

Duplex with an open character device, taking ownership of it.

Duplex with an open TCP stream, taking ownership of it.

This method can be passed a std::net::TcpStream or similar TcpStream types.

Duplex with an open Unix-domain stream, taking ownership of it.

Duplex with a pair of pipe streams, taking ownership of them.

This is supported on non-WASI and crate feature socketpair only.

Duplex with one end of a socketpair stream, taking ownership of it.

Spawn the given command and duplex with its standard input and output.

Duplex with a child process’ stdout and stdin, taking ownership of them.

This is supported on non-WASI and crate feature socketpair only.

Duplex with a duplexer from on another thread through a socketpair.

A socketpair is created, new thread is created, boxed_duplex is read from and written to over the socketpair.

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.

This is supported on non-WASI and crate feature socketpair only.

Duplex with a duplexer from on another thread through a socketpair.

A socketpair is created, new thread is created, boxed_duplex is written to and read from over the socketpair.

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.

This is supported on non-WASI and crate feature socketpair only.

Duplex with a duplexer from on another thread through a socketpair.

A socketpair is created, new thread is created, boxed_duplex is written to and/or read from over the socketpair. ReadReady::num_ready_bytes is used to determine whether to read from or write to boxed_duplex first. This may be inefficient, so if you know which direction should go first, use socketed_thread_read_first or socketed_thread_write_first instead.

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.

This is supported on non-WASI and crate feature socketpair only.

Duplex with a function running on another thread through a socketpair.

A socketpair is created, new thread is created, func is called in the new thread and passed one of the ends of the socketstream.

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.

Read and write with the null device, which ignores all data, and produces no data.

Trait Implementations

Extracts the raw file descriptor for reading. Read more

Extracts the raw file descriptor for writing. Read more

Extracts the file descriptor for reading. Read more

Extracts the file descriptor for writing. Read more

Formats the value using the given formatter. Read more

Reads data from a stream without consuming it; subsequent reads will re-read the data. May return fewer bytes than requested; Ok(0) indicates that seeking is not possible (but reading may still be). Read more

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Like read, except that it reads into a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, appending them to buf. Read more

Read the exact number of bytes required to fill buf. Read more

🔬 This is a nightly-only experimental API. (read_buf)

Pull some bytes from this source into the specified buffer. Read more

🔬 This is a nightly-only experimental API. (read_buf)

Read the exact number of bytes required to fill buf. Read more

Creates a “by reference” adaptor for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Creates an adapter which will read at most limit bytes from it. Read more

Return the number of bytes which are ready to be read immediately.

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Extracts the grip for reading. Read more

Extracts the grip for writing. Read more

Extracts the grip for reading. Read more

Extracts the grip for writing. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Query the “status” flags for the self file descriptor.

Create a new SetFdFlags value for use with set_fd_flags. Read more

Set the “status” flags for the self file descriptor. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.