pub struct NamedPipe { /* private fields */ }
Expand description
Representation of a named pipe on Windows.
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.
Implementations§
Source§impl NamedPipe
impl NamedPipe
Sourcepub fn new<A: AsRef<OsStr>>(addr: A) -> Result<NamedPipe>
pub fn new<A: AsRef<OsStr>>(addr: A) -> Result<NamedPipe>
Creates a new named pipe at the specified addr
given a “reasonable
set” of initial configuration options.
Currently the configuration options are the same as miow. To change
these options, you can create a custom named pipe yourself and then use
the FromRawHandle
constructor to convert that type to an instance of a
NamedPipe
in this crate.
Sourcepub fn connect(&self) -> Result<()>
pub fn connect(&self) -> Result<()>
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.
Sourcepub fn take_error(&self) -> Result<Option<Error>>
pub fn take_error(&self) -> Result<Option<Error>>
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.
Sourcepub fn disconnect(&self) -> Result<()>
pub fn disconnect(&self) -> Result<()>
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. If the
disconnection is successful then this object will no longer be readable
or writable.
After a disconnect
is issued, then a connect
may be called again to
connect to another client.
Trait Implementations§
Source§impl AsRawHandle for NamedPipe
impl AsRawHandle for NamedPipe
Source§fn as_raw_handle(&self) -> RawHandle
fn as_raw_handle(&self) -> RawHandle
Source§impl Evented for NamedPipe
impl Evented for NamedPipe
Source§impl FromRawHandle for NamedPipe
impl FromRawHandle for NamedPipe
Source§impl<'a> Read for &'a NamedPipe
impl<'a> Read for &'a NamedPipe
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moreSource§impl Read for NamedPipe
impl Read for NamedPipe
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf
. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read moreSource§impl<'a> Write for &'a NamedPipe
impl<'a> Write for &'a NamedPipe
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)Source§impl Write for NamedPipe
impl Write for NamedPipe
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)