Struct io_streams::StreamReader[][src]

pub struct StreamReader { /* fields omitted */ }

An unbuffered and unlocked input byte stream, abstracted over the source of the input.

It primarily consists of a single file handle, and also contains any resources needed to safely hold the file handle live.

Since it is unbuffered, and since many input sources have high per-call overhead, it is often beneficial to wrap this in a BufReader.

Implementations

impl StreamReader[src]

pub fn stdin() -> Result<Self>[src]

Read from standard input.

Unlike std::io::stdin, this stdin returns a stream which is unbuffered and unlocked.

This acquires a std::io::StdinLock to prevent accesses to std::io::Stdin while this is live, and fails if a StreamReader or StreamDuplexer for standard input already exists.

#[must_use]pub fn file<Filelike: IntoUnsafeFile + Read + Write + Seek>(
    filelike: Filelike
) -> Self
[src]

Read from an open file, taking ownership of it.

This method can be passed a std::fs::File or similar File types.

#[must_use]pub fn tcp_stream<Socketlike: IntoUnsafeSocket>(socketlike: Socketlike) -> Self[src]

Read from an open TCP stream, taking ownership of it.

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

#[must_use]pub fn unix_stream(unix_stream: UnixStream) -> Self[src]

Read from an open Unix-domain socket, taking ownership of it.

#[must_use]pub fn pipe_reader(pipe_reader: PipeReader) -> Self[src]

Read from the reading end of an open pipe, taking ownership of it.

pub fn read_from_command(mut command: Command) -> Result<Self>[src]

Spawn the given command and read from its standard output.

#[must_use]pub fn child_stdout(child_stdout: ChildStdout) -> Self[src]

Read from a child process' standard output, taking ownership of it.

#[must_use]pub fn child_stderr(child_stderr: ChildStderr) -> Self[src]

Read from a child process' standard error, taking ownership of it.

pub fn piped_thread(mut boxed_read: Box<dyn Read + Send>) -> Result<Self>[src]

Read from a boxed Read implementation, taking ownership of it. This works by creating a new thread to read the data and write it through a pipe.

pub fn str<S: AsRef<str>>(s: S) -> Result<Self>[src]

Read from the given string.

pub fn bytes(bytes: &[u8]) -> Result<Self>[src]

Read from the given bytes.

Trait Implementations

impl AsRawFd for StreamReader[src]

impl Debug for StreamReader[src]

impl Peek for StreamReader[src]

impl Read for StreamReader[src]

impl ReadReady for StreamReader[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsUnsafeFile for T where
    T: AsRawFd
[src]

impl<T> AsUnsafeHandle for T where
    T: AsRawFd
[src]

impl<T> AsUnsafeSocket for T where
    T: AsRawFd
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> FileIoExt for T where
    T: AsRawFd
[src]

impl<T> From<T> for T[src]

impl<T> GetSetFdFlags for T where
    T: AsUnsafeFile
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IsReadWrite for T where
    T: AsRawFd
[src]

impl<T> IsTerminal for T where
    T: AsRawFd
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.