[][src]Struct mio::windows::NamedPipe

pub struct NamedPipe { /* fields omitted */ }
This is supported on Windows and crate feature os-util only.

Non-blocking windows named pipe.

This structure internally contains a HANDLE which represents the named pipe, and also maintains state associated with the mio event loop and active I/O operations that have been scheduled to translate IOCP to a readiness model.

Note, IOCP is a completion based model whereas mio is a readiness based model. To bridge this, NamedPipe performs internal buffering. Writes are written to an internal buffer and the buffer is submitted to IOCP. IOCP reads are submitted using internal buffers and NamedPipe::read reads from this internal buffer.

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.

Implementations

impl NamedPipe[src]

pub fn new<A: AsRef<OsStr>>(addr: A) -> Result<NamedPipe>[src]

This is supported on crate feature os-poll only.

Creates a new named pipe at the specified addr given a "reasonable set" of initial configuration options.

pub fn connect(&self) -> Result<()>[src]

This is supported on crate feature os-poll only.

Attempts to call ConnectNamedPipe, if possible.

This function will attempt to connect this pipe to a client in an asynchronous fashion. If the function immediately establishes a connection to a client then Ok(()) is returned. Otherwise if a connection attempt was issued and is now in progress then a "would block" error is returned.

When the connection is finished then this object will be flagged as being ready for a write, or otherwise in the writable state.

Errors

This function will return a "would block" error if the pipe has not yet been registered with an event loop, if the connection operation has previously been issued but has not yet completed, or if the connect itself was issued and didn't finish immediately.

Normal I/O errors from the call to ConnectNamedPipe are returned immediately.

pub fn take_error(&self) -> Result<Option<Error>>[src]

This is supported on crate feature os-poll only.

Takes any internal error that has happened after the last I/O operation which hasn't been retrieved yet.

This is particularly useful when detecting failed attempts to connect. After a completed connect flags this pipe as writable then callers must invoke this method to determine whether the connection actually succeeded. If this function returns None then a client is connected, otherwise it returns an error of what happened and a client shouldn't be connected.

pub fn disconnect(&self) -> Result<()>[src]

This is supported on crate feature os-poll only.

Disconnects this named pipe from a connected client.

This function will disconnect the pipe from a connected client, if any, transitively calling the DisconnectNamedPipe function.

After a disconnect is issued, then a connect may be called again to connect to another client.

Trait Implementations

impl AsRawHandle for NamedPipe[src]

impl Debug for NamedPipe[src]

impl Drop for NamedPipe[src]

impl FromRawHandle for NamedPipe[src]

impl Read for NamedPipe[src]

impl<'a> Read for &'a NamedPipe[src]

impl Source for NamedPipe[src]

impl Write for NamedPipe[src]

impl<'a> Write for &'a NamedPipe[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.