Crate mio_named_pipes

Source
Expand description

Windows named pipes bindings for mio.

This crate implements bindings for named pipes for the mio crate. This crate compiles on all platforms but only contains anything on Windows. Currently this crate requires mio 0.6.2.

On Windows, mio is implemented with an IOCP object at the heart of its Poll implementation. For named pipes, this means that all I/O is done in an overlapped fashion and the named pipes themselves are registered with mio’s internal IOCP object. Essentially, this crate is using IOCP for bindings with named pipes.

Note, though, that IOCP is a completion based model whereas mio expects a readiness based model. As a result this crate, like with TCP objects in mio, has internal buffering to translate the completion model to a readiness model. This means that this crate is not a zero-cost binding over named pipes on Windows, but rather approximates the performance of mio’s TCP implementation on Windows.

§Trait implementations

The Read and Write traits are implemented for NamedPipe and for &NamedPipe. This represents that a named pipe can be concurrently read and written to and also can be read and written to at all. Typically a named pipe needs to be connected to a client before it can be read or written, however.

Note that for I/O operations on a named pipe to succeed then the named pipe needs to be associated with an event loop. Until this happens all I/O operations will return a “would block” error.

§Managing connections

The NamedPipe type supports a connect method to connect to a client and a disconnect method to disconnect from that client. These two methods only work once a named pipe is associated with an event loop.

The connect method will succeed asynchronously and a completion can be detected once the object receives a writable notification.

§Named pipe clients

Currently to create a client of a named pipe server then you can use the OpenOptions type in the standard library to create a File that connects to a named pipe. Afterwards you can use the into_raw_handle method coupled with the NamedPipe::from_raw_handle method to convert that to a named pipe that can operate asynchronously. Don’t forget to pass the FILE_FLAG_OVERLAPPED flag when opening the File.

Structs§

  • Representation of a named pipe on Windows.