pub struct MsgReaderPipeStream { /* private fields */ }
Expand description
Message stream reader for a named pipe.
Created either by using PipeListener
or by connecting to a named pipe server.
Implementations§
Source§impl MsgReaderPipeStream
impl MsgReaderPipeStream
Sourcepub fn connect(name: impl AsRef<OsStr>) -> Result<Self>
pub fn connect(name: impl AsRef<OsStr>) -> Result<Self>
Connects to the specified named pipe (the \\.\pipe\
prefix is added automatically), blocking until a server instance is dispatched.
Sourcepub fn connect_to_remote(
pipe_name: impl AsRef<OsStr>,
hostname: impl AsRef<OsStr>,
) -> Result<Self>
pub fn connect_to_remote( pipe_name: impl AsRef<OsStr>, hostname: impl AsRef<OsStr>, ) -> Result<Self>
Connects to the specified named pipe at a remote computer (the \\<hostname>\pipe\
prefix is added automatically), blocking until a server instance is dispatched.
Sourcepub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
Sets whether the nonblocking mode for the pipe stream is enabled. By default, it is disabled.
In nonblocking mode, attempts to read from the pipe when there is no data available or to write when the buffer has filled up because the receiving side did not read enough bytes in time will never block like they normally do. Instead, a WouldBlock
error is immediately returned, allowing the thread to perform useful actions in the meantime.
If called on the server side, the flag will be set only for one stream instance. A listener creation option, nonblocking
, and a similar method on the listener, set_nonblocking
, can be used to set the mode in bulk for all current instances and future ones.
Sourcepub fn is_server(&self) -> bool
pub fn is_server(&self) -> bool
Returns true
if the stream was created by a listener (server-side), false
if it was created by connecting to a server (server-side).
Sourcepub fn is_client(&self) -> bool
pub fn is_client(&self) -> bool
Returns true
if the stream was created by connecting to a server (client-side), false
if it was created by a listener (server-side).
Sourcepub fn client_process_id(&self) -> Result<u32>
pub fn client_process_id(&self) -> Result<u32>
Retrieves the process identifier of the client side of the named pipe connection.
Sourcepub fn client_session_id(&self) -> Result<u32>
pub fn client_session_id(&self) -> Result<u32>
Retrieves the session identifier of the client side of the named pipe connection.
Sourcepub fn server_process_id(&self) -> Result<u32>
pub fn server_process_id(&self) -> Result<u32>
Retrieves the process identifier of the server side of the named pipe connection.
Sourcepub fn server_session_id(&self) -> Result<u32>
pub fn server_session_id(&self) -> Result<u32>
Retrieves the session identifier of the server side of the named pipe connection.
Sourcepub fn disconnect_without_flushing(self) -> Result<()>
pub fn disconnect_without_flushing(self) -> Result<()>
Disconnects the named pipe stream without flushing buffers, causing all data in those buffers to be lost. This is much faster (and, in some case, the only finite-time way of ending things) than simply dropping the stream, since, for non-async named pipes, the Drop
implementation flushes first.
Only makes sense for server-side pipes and will return an error if called on a client stream. For async pipe streams, this is the same as dropping the pipe.
Trait Implementations§
Source§impl Debug for MsgReaderPipeStream
impl Debug for MsgReaderPipeStream
Source§impl Drop for MsgReaderPipeStream
impl Drop for MsgReaderPipeStream
Source§impl PipeStream for MsgReaderPipeStream
impl PipeStream for MsgReaderPipeStream
Source§const ROLE: PipeStreamRole = PipeStreamRole::Reader
const ROLE: PipeStreamRole = PipeStreamRole::Reader
PipeStreamRole
enumeration for more on what this means.Source§const WRITE_MODE: Option<PipeMode> = None
const WRITE_MODE: Option<PipeMode> = None
PipeMode::Bytes
, message boundaries will broken and having READ_MODE
at PipeMode::Messages
would be a pipe creation error. Read moreSource§const READ_MODE: Option<PipeMode>
const READ_MODE: Option<PipeMode>
WRITE_MODE
is PipeMode::Messages
and READ_MODE
is PipeMode::Bytes
, the message boundaries will be destroyed when reading even though they are retained when written. See the PipeMode
enumeration for more on what those modes mean. Read moreSource§impl Read for MsgReaderPipeStream
impl Read for MsgReaderPipeStream
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 ReliableReadMsg for MsgReaderPipeStream
impl ReliableReadMsg for MsgReaderPipeStream
Source§fn read_msg(&mut self, buf: &mut [u8]) -> Result<Result<usize, Vec<u8>>>
fn read_msg(&mut self, buf: &mut [u8]) -> Result<Result<usize, Vec<u8>>>
Result
if the operation could not be completed for OS reasons.Source§fn try_read_msg(&mut self, buf: &mut [u8]) -> Result<Result<usize, usize>>
fn try_read_msg(&mut self, buf: &mut [u8]) -> Result<Result<usize, usize>>
Ok
or Err
variant, either did fit or did not fit into the provided buffer, respectively; if the operation could not be completed for OS reasons, an error from the outermost Result
is returned.