Struct MsgReaderPipeStream

Source
pub struct MsgReaderPipeStream { /* private fields */ }
Available on Windows only.
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

Source

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.

Source

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.

Source

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.

Source

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).

Source

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).

Source

pub fn client_process_id(&self) -> Result<u32>

Retrieves the process identifier of the client side of the named pipe connection.

Source

pub fn client_session_id(&self) -> Result<u32>

Retrieves the session identifier of the client side of the named pipe connection.

Source

pub fn server_process_id(&self) -> Result<u32>

Retrieves the process identifier of the server side of the named pipe connection.

Source

pub fn server_session_id(&self) -> Result<u32>

Retrieves the session identifier of the server side of the named pipe connection.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for MsgReaderPipeStream

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PipeStream for MsgReaderPipeStream

Source§

const ROLE: PipeStreamRole = PipeStreamRole::Reader

The data stream flow direction for the pipe. See the PipeStreamRole enumeration for more on what this means.
Source§

const WRITE_MODE: Option<PipeMode> = None

The data stream mode for the pipe. If set to PipeMode::Bytes, message boundaries will broken and having READ_MODE at PipeMode::Messages would be a pipe creation error. Read more
Source§

const READ_MODE: Option<PipeMode>

The data stream mode used when reading from the pipe: if 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 more
Source§

impl Read for MsgReaderPipeStream

Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

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

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

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

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

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

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

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

impl ReliableReadMsg for MsgReaderPipeStream

Source§

fn read_msg(&mut self, buf: &mut [u8]) -> Result<Result<usize, Vec<u8>>>

Reads one message from the stream into the specified buffer, returning either the size of the message written, a bigger buffer if the one provided was too small, or an error in the outermost 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>>

Attempts to read one message from the stream into the specified buffer, returning the size of the message, which, depending on whether it was in the 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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> To for T
where T: ?Sized,

Source§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
Source§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.