[−][src]Struct mio::windows::NamedPipe
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]
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]
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]
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]
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]
fn as_raw_handle(&self) -> RawHandle
[src]
impl Debug for NamedPipe
[src]
impl Drop for NamedPipe
[src]
impl FromRawHandle for NamedPipe
[src]
unsafe fn from_raw_handle(handle: RawHandle) -> NamedPipeⓘ
[src]
impl Read for NamedPipe
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_read_vectored(&self) -> bool
[src]
unsafe fn initializer(&self) -> Initializer
[src]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn bytes(self) -> Bytes<Self>
1.0.0[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl<'a> Read for &'a NamedPipe
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_read_vectored(&self) -> bool
[src]
unsafe fn initializer(&self) -> Initializer
[src]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn bytes(self) -> Bytes<Self>
1.0.0[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl Source for NamedPipe
[src]
fn register(
&mut self,
registry: &Registry,
token: Token,
interest: Interest
) -> Result<()>
[src]
&mut self,
registry: &Registry,
token: Token,
interest: Interest
) -> Result<()>
fn reregister(
&mut self,
registry: &Registry,
token: Token,
interest: Interest
) -> Result<()>
[src]
&mut self,
registry: &Registry,
token: Token,
interest: Interest
) -> Result<()>
fn deregister(&mut self, registry: &Registry) -> Result<()>
[src]
impl Write for NamedPipe
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
impl<'a> Write for &'a NamedPipe
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl !RefUnwindSafe for NamedPipe
impl Send for NamedPipe
impl Sync for NamedPipe
impl Unpin for NamedPipe
impl !UnwindSafe for NamedPipe
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,