Struct miow::pipe::NamedPipe

source ·
pub struct NamedPipe(_);
Expand description

A named pipe that can accept connections.

Implementations§

source§

impl NamedPipe

source

pub fn new<A: AsRef<OsStr>>(addr: A) -> Result<NamedPipe>

Creates a new initial named pipe.

This function is equivalent to:

use miow::pipe::NamedPipeBuilder;

NamedPipeBuilder::new(addr)
                 .first(true)
                 .inbound(true)
                 .outbound(true)
                 .out_buffer_size(65536)
                 .in_buffer_size(65536)
                 .create();
source

pub fn wait<A: AsRef<OsStr>>(addr: A, timeout: Option<Duration>) -> Result<()>

Waits until either a time-out interval elapses or an instance of the specified named pipe is available for connection.

If this function succeeds the process can create a File to connect to the named pipe.

source

pub fn connect(&self) -> Result<()>

Connects this named pipe to a client, blocking until one becomes available.

This function will call the ConnectNamedPipe function to await for a client to connect. This can be called immediately after the pipe is created, or after it has been disconnected from a previous client.

source

pub unsafe fn connect_overlapped( &self, overlapped: *mut OVERLAPPED ) -> Result<bool>

Issue a connection request with the specified overlapped operation.

This function will issue a request to connect a client to this server, returning immediately after starting the overlapped operation.

If this function immediately succeeds then Ok(true) is returned. If the overlapped operation is enqueued and pending, then Ok(false) is returned. Otherwise an error is returned indicating what went wrong.

Unsafety

This function is unsafe because the kernel requires that the overlapped pointer is valid until the end of the I/O operation. The kernel also requires that overlapped is unique for this I/O operation and is not in use for any other I/O.

To safely use this function callers must ensure that this pointer is valid until the I/O operation is completed, typically via completion ports and waiting to receive the completion notification on the port.

source

pub fn disconnect(&self) -> Result<()>

Disconnects this named pipe from any connected client.

source

pub unsafe fn read_overlapped( &self, buf: &mut [u8], overlapped: *mut OVERLAPPED ) -> Result<Option<usize>>

Issues an overlapped read operation to occur on this pipe.

This function will issue an asynchronous read to occur in an overlapped fashion, returning immediately. The buf provided will be filled in with data and the request is tracked by the overlapped function provided.

If the operation succeeds immediately, Ok(Some(n)) is returned where n is the number of bytes read. If an asynchronous operation is enqueued, then Ok(None) is returned. Otherwise if an error occurred it is returned.

When this operation completes (or if it completes immediately), another mechanism must be used to learn how many bytes were transferred (such as looking at the filed in the IOCP status message).

Unsafety

This function is unsafe because the kernel requires that the buf and overlapped pointers to be valid until the end of the I/O operation. The kernel also requires that overlapped is unique for this I/O operation and is not in use for any other I/O.

To safely use this function callers must ensure that the pointers are valid until the I/O operation is completed, typically via completion ports and waiting to receive the completion notification on the port.

source

pub unsafe fn write_overlapped( &self, buf: &[u8], overlapped: *mut OVERLAPPED ) -> Result<Option<usize>>

Issues an overlapped write operation to occur on this pipe.

This function will issue an asynchronous write to occur in an overlapped fashion, returning immediately. The buf provided will be filled in with data and the request is tracked by the overlapped function provided.

If the operation succeeds immediately, Ok(Some(n)) is returned where n is the number of bytes written. If an asynchronous operation is enqueued, then Ok(None) is returned. Otherwise if an error occurred it is returned.

When this operation completes (or if it completes immediately), another mechanism must be used to learn how many bytes were transferred (such as looking at the filed in the IOCP status message).

Unsafety

This function is unsafe because the kernel requires that the buf and overlapped pointers to be valid until the end of the I/O operation. The kernel also requires that overlapped is unique for this I/O operation and is not in use for any other I/O.

To safely use this function callers must ensure that the pointers are valid until the I/O operation is completed, typically via completion ports and waiting to receive the completion notification on the port.

source

pub unsafe fn result(&self, overlapped: *mut OVERLAPPED) -> Result<usize>

Calls the GetOverlappedResult function to get the result of an overlapped operation for this handle.

This function takes the OVERLAPPED argument which must have been used to initiate an overlapped I/O operation, and returns either the successful number of bytes transferred during the operation or an error if one occurred.

Unsafety

This function is unsafe as overlapped must have previously been used to execute an operation for this handle, and it must also be a valid pointer to an Overlapped instance.

Panics

This function will panic

Trait Implementations§

source§

impl AsRawHandle for NamedPipe

source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
source§

impl Debug for NamedPipe

source§

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

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

impl FromRawHandle for NamedPipe

source§

unsafe fn from_raw_handle(handle: RawHandle) -> NamedPipe

Constructs a new I/O object from the specified raw handle. Read more
source§

impl IntoRawHandle for NamedPipe

source§

fn into_raw_handle(self) -> RawHandle

Consumes this object, returning the raw underlying handle. Read more
source§

impl<'a> Read for &'a NamedPipe

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, Global>) -> Result<usize, Error>

Read 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>

Read 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>

Read 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)
Read the exact number of bytes required to fill cursor. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere 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 Read for NamedPipe

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, Global>) -> Result<usize, Error>

Read 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>

Read 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>

Read 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)
Read the exact number of bytes required to fill cursor. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere 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<'a> Write for &'a NamedPipe

source§

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

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

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

Flush 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, fmt: 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 Selfwhere Self: Sized,

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

impl Write for NamedPipe

source§

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

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

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

Flush 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, fmt: 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 Selfwhere Self: Sized,

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.