ipipe - A cross-platform named-pipe library for Rust
This library allows the creation of platform-independant named pipes. Standard Read/Write traits are implemented. Higher level/more fleshed-out APIs are under development and will be added in future versions. Improvements and PRs welcome.
Example:
use Pipe;
use thread;
use ;
use ;
const CANCEL: u8 = 24;
Running the above example program will output:
1
2
3
4
5
6
7
8
9
10
Pipe::create
generates a random pipe name in a temporary location.
Example path (Windows):
\\.\pipe\pipe_23676_xMvclVhNKcg6iGf
Example path (Unix):
/tmp/pipe_1230_mFP8dx8uVl
Pipe::with_name
allows a pipe name to be specified.
The 'static_pipe' feature
Enabling the static_pipe
feature allows the creation of mutex-protected static pipes that can be written to from anywhere in a way that mimics stdout. Here's an example:
use *;
use ;
let mut reader = init.unwrap;
// You can get a handle to an already-initialized pipe like this:
// let mut reader = ipipe::get("my_pipe");
let s = new.lines.next.unwrap;
println!;
// Drops the static pipe. Can also call `ipipe::close_all()` to drop all static pipes.
close;
Then anywhere your program (or another program with enough permission to access the pipe) can write code like this:
pprintln!;
Lower level as well as more complete/intuitive APIs to the static pipes are also planned for a future release.
Development Notes
This project is very bare-bones in its current state, a proof-of-concept with some degree of practical usability at best. At this point, developers willing to contribute and improve would be very-much appreciated. As Windows named pipes work substantially different than Unix named pipes, there are likely unintuitive "features" of this crate in its current state when traveling from one platform to another. Sniping those is top priority.