MsgWriterPipeStream

Struct MsgWriterPipeStream 

Source
pub struct MsgWriterPipeStream { /* private fields */ }
Available on Windows only.
Expand description

Message stream writer for a named pipe.

Created either by using PipeListener or by connecting to a named pipe server.

Implementations§

Source§

impl MsgWriterPipeStream

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 MsgWriterPipeStream

Source§

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

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

impl Drop for MsgWriterPipeStream

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PipeStream for MsgWriterPipeStream

Source§

const ROLE: PipeStreamRole = PipeStreamRole::Writer

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

const WRITE_MODE: Option<PipeMode>

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> = None

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 Write for MsgWriterPipeStream

Source§

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

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

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

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

fn is_write_vectored(&self) -> bool

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

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

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

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

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

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

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.