Crate ipipe

source · []
Expand description

Cross-platform named-pipe API.

Quick Start

To get started quickly, try using Pipe::with_name to create a pipe with a given name.

use ipipe::Pipe; 
use std::io::BufRead;
fn reader()
{
    let mut pipe = Pipe::with_name("test_pipe").unwrap();
    println!("Pipe path: {}", pipe.path().display());

    // Read lines
    for line in std::io::BufReader::new(pipe).lines()
    {
        println!("{}", line.unwrap());
    }
}

Then in another program or thread:

use ipipe::Pipe; 
use std::io::Write;
fn writer()
{
    let mut pipe = Pipe::with_name("test_pipe").unwrap();
    writeln!(&mut pipe, "This is only a test.").unwrap();
}

You can also use Pipe::create to open a pipe with a randomly-generated name, which can then be accessed by calling Pipe::path.

Lastly, Pipe::open can be used to specify an exact path. This is not platform agnostic, however, as Windows pipe paths require a special format.

Calling clone() on a pipe will create a pipe who’s handle exists as a Weak reference to the original pipe. That means dropping the original pipe will also close all of its clones. If a clone is in the middle of a read or write when the drop of the original pipe happens, the pipe will not be closed until that read or write is complete.

Macros

Print a string to a static pipe

Print a string and a trailing newline to a static pipe

Structs

Abstraction over a named pipe

Enums

Standard error type used by this library

Functions

Closes a static pipe

Closes all static pipes

Get a handle to an existing static pipe

Initialize a static pipe and return a handle to it.

The lowest-level static-pipe print function. Panics if pipe is not initialized.

Type Definitions