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

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

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

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.

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.

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.

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

Extracts the raw handle, without taking any ownership.

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Constructs a new I/O object from the specified raw handle. Read more

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Like read, except that it reads into a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, appending them to buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a “by reference” adapter for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Creates an adapter which will read at most limit bytes from it. Read more

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

Like read, except that it reads into a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

Read all bytes until EOF in this source, placing them into buf. Read more

Read all bytes until EOF in this source, appending them to buf. Read more

Read the exact number of bytes required to fill buf. Read more

Creates a “by reference” adapter for this instance of Read. Read more

Transforms this Read instance to an Iterator over its bytes. Read more

Creates an adapter which will chain this stream with another. Read more

Creates an adapter which will read at most limit bytes from it. Read more

Register self with the given Registry instance. Read more

Re-register self with the given Registry instance. Read more

Deregister self from the given Registry instance. Read more

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.