Struct ipipe::Pipe[][src]

pub struct Pipe { /* fields omitted */ }

Abstraction over a named pipe

Implementations

impl Pipe[src]

pub fn open(path: &Path, on_cleanup: OnCleanup) -> Result<Self>[src]

Open an existing pipe. If on_cleanup is set to ‘DeleteOnDrop’ the named pipe will be deleted when the returned struct is deallocated. Note that this function is not platform-agnostic as unix pipe paths and Windows pipe paths are formatted differnetly.

pub fn with_name(name: &str, on_cleanup: OnCleanup) -> Result<Self>[src]

Open or create a pipe with the given name. Note that this is just a string name, not a path.

pub fn create(on_cleanup: OnCleanup) -> Result<Self>[src]

Create a pipe with a randomly generated name in a tempory directory. If on_cleanup is set to ‘DeleteOnDrop’ the named pipe will be deleted when the returned struct is deallocated.

pub fn close(&mut self) -> Result<()>[src]

Close the pipe. If the pipe is not closed before deallocation, this will be called automatically on drop.

pub fn write_byte(&mut self, buf: u8) -> Result<usize>[src]

Write a single byte to the pipe

pub fn write_bytes(&mut self, buf: &[u8]) -> Result<usize>[src]

Write an array of bytes to the pipe

pub fn write_string(&mut self, s: &str) -> Result<usize>[src]

Writes a string to the pipe

pub fn read_byte(&mut self) -> Result<u8>[src]

Read a single byte

pub fn read_bytes(&mut self, size: usize) -> Result<Vec<u8>>[src]

Reads the given number of bytes and returns the result in a vector.

pub fn read_string(&mut self, size: usize) -> Result<String>[src]

Reads the given number of bytes and returns the result as a string.

pub fn flush_pipe(&self) -> Result<()>[src]

Flush input and output.

impl Pipe[src]

pub fn path(&self) -> &Path[src]

Return the path to this named pipe

pub fn iter(&mut self) -> FifoIterator<'_>

Notable traits for FifoIterator<'_>

impl Iterator for FifoIterator<'_> type Item = u8;
[src]

Creates an iterator that reads bytes until the pipe is closed.

pub fn read_bytes_while(
    &mut self,
    predicate: impl Fn(u8) -> bool
) -> Result<Vec<u8>>
[src]

Reads until the given predicate is false, and returns the result as a vector of bytes.

pub fn read_string_while(
    &mut self,
    predicate: impl Fn(u8) -> bool
) -> Result<String>
[src]

Reads until the given predicate is false, and returns the result as a string.

Trait Implementations

impl Clone for Pipe[src]

fn clone(&self) -> Self[src]

Cloning a pipe creates a slave which points to the same path but does not close the pipe when dropped.

impl Drop for Pipe[src]

impl Read for Pipe[src]

impl Write for Pipe[src]

Auto Trait Implementations

impl RefUnwindSafe for Pipe

impl Send for Pipe

impl Sync for Pipe

impl Unpin for Pipe

impl UnwindSafe for Pipe

Blanket Implementations

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.