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§

pprint
Print a string to a static pipe
pprintln
Print a string and a trailing newline to a static pipe

Structs§

Pipe
Abstraction over a named pipe

Enums§

Error
Standard error type used by this library
OnCleanup

Functions§

close
Closes a static pipe
close_all
Closes all static pipes
get
Get a handle to an existing static pipe
init
Initialize a static pipe and return a handle to it.
print
The lowest-level static-pipe print function. Panics if pipe is not initialized.

Type Aliases§

Result