Available on Windows only.
Expand description

Support for named pipes on Windows.

Windows named pipes are not Unix named pipes

The term “named pipe” refers to completely different things in Unix and Windows. For this reason, Unix named pipes are referred to as “FIFO files” to avoid confusion with the more powerful Windows named pipes. In fact, the only common features for those two is that they both can be located using filesystem paths and they both use a stream interface. The differences can be summed up like this:

  • Windows named pipes are located on a separate filesystem (NPFS – Named Pipe Filesystem), while Unix FIFO files live in the shared filesystem tree together with all other files
    • On Linux, the implementation of Unix domain sockets exposes a similar feature: by setting the first byte in the socket file path to NULL (\0), the socket is placed into a separate namespace instead of being placed on the filesystem; this is a non-standard extension to POSIX and is not available on other Unix systems
  • Windows named pipes have a server and an arbitrary number of clients, meaning that the separate processes connecting to a named pipe have separate connections to the server, while Unix FIFO files don’t have the notion of a server or client and thus mix all data written into one sink from which the data is read by one process
  • Windows named pipes can be used over the network, while a Unix FIFO file is still local even if created in a directory which is a mounted network filesystem
  • Windows named pipes can maintain datagram boundaries, allowing both sides of the connection to operate on separate messages rather than on a byte stream, while FIFO files, like any other type of file, expose only a byte stream interface

If you carefully read through this list, you’d notice how Windows named pipes are similar to Unix domain sockets. For this reason, the implementation of “local sockets” in the local_socket module of this crate uses named pipes on Windows and Ud-sockets on Unix.

Structs

Enums

  • The direction of a named pipe connection, designating who can read data and who can write it. This describes the direction of the data flow unambiguously, so that the meaning of the values is the same for the client and server – ClientToServer always means client → server, for example.
  • Specifies the mode for a pipe stream.
  • Describes the role of a named pipe stream. In constrast to PipeDirection, the meaning of values here is relative – for example, Reader means ServerToClient if you’re creating a server and ClientToServer if you’re creating a client.

Traits

  • Defines the properties of pipe stream types.

Functions

  • connectDeprecated
    Tries to connect to the specified named pipe (the \\.\pipe\ prefix is added automatically), returning a named pipe stream of the stream type provided via generic parameters. If there is no available server, returns immediately.