Skip to main content

WindowsUnixStream

Struct WindowsUnixStream 

Source
pub struct WindowsUnixStream { /* private fields */ }
Expand description

An unix domain stream packet connection for Windows.

It requires WSA version 2.0 or 2.2 i.e Windows 10 and above.

The crate requests version 2.2 by default!

Is simular to the UnixStream but with some limitations:

  • no SOCK_DGRAM or SOCK_SEQPACKET support

  • Ancillary data like SCM_RIGHTS SCM_CREDENTIALS

  • Autobind feature

  • socketpair

§Examples

let path = "server3.sock";
 
let client = WindowsUnixStream::connect(path).unwrap();
client.send(b"first").unwrap();
client.send(b"second").unwrap();

Implementations§

Source§

impl WindowsUnixStream

Source

pub fn connect<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Connects to an unix stream server listening at path.

This is a wrapper around connect_unix_addr() for convenience and compatibility with std.

Source

pub fn connect_unix_addr(addr: &UnixSocketAddr) -> Result<Self, Error>

Connects to an unix seqpacket server listening at addr.

Source

pub fn connect_from_to_unix_addr( from: &UnixSocketAddr, to: &UnixSocketAddr, ) -> Result<Self, Error>

Binds to an address before connecting to a listening seqpacet socket.

Source

pub fn pair() -> Result<(Self, Self), Error>

Creates a socket pair.

Source

pub fn try_clone(&self) -> Result<Self>

Source

pub fn set_nonblocking(&self, nonblk: bool) -> Result<()>

Source

pub fn set_no_inherit(&self, no_inh: bool) -> Result<()>

Cloexec

Source

pub fn set_write_timeout(&self, timeout: Option<Duration>) -> Result<()>

Source

pub fn write_timeout(&self) -> Result<Option<Duration>>

Source

pub fn set_read_timeout(&self, timeout: Option<Duration>) -> Result<()>

Source

pub fn read_timeout(&self) -> Result<Option<Duration>>

Source

pub fn local_unix_addr(&self) -> Result<UnixSocketAddr, Error>

Returns the address of this side of the connection.

Source

pub fn peer_unix_addr(&self) -> Result<UnixSocketAddr, Error>

Returns the address of the other side of the connection.

Source

pub fn send(&self, packet: &[u8]) -> Result<usize, Error>

Sends a packet to the peer.

Source

pub fn recv(&self, buffer: &mut [u8]) -> Result<usize, Error>

Receives a packet from the peer.

Source

pub fn recv_vectored( &self, bufs: &mut [IoSliceMut<'_>], ) -> Result<(usize, RecvFlags)>

Source

pub fn send_vectored(&self, bufs: Vec<IoSlice<'_>>) -> Result<usize>

Windows consumes the io::IoSlice instances, so can no logner be accessed. The io::Write borrows, but it is not correct. DO not access the slices after it were sent.

Source

pub fn take_error(&self) -> Result<Option<Error>, Error>

Returns the value of the SO_ERROR option.

This might only provide errors generated from nonblocking connect()s, which this library doesn’t support. It is therefore unlikely to be useful, but is provided for parity with stream counterpart in std.

Source

pub fn shutdown(&self, how: Shutdown) -> Result<()>

Allows to shudown receiving/sending or both sides.

Trait Implementations§

Source§

impl AsRawSocket for WindowsUnixStream

Source§

fn as_raw_socket(&self) -> RawSocket

Extracts the raw socket. Read more
Source§

impl AsSocket for WindowsUnixStream

Source§

fn as_socket(&self) -> BorrowedSocket<'_>

Borrows the socket.
Source§

impl Debug for WindowsUnixStream

Source§

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

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

impl From<OwnedSocket> for WindowsUnixStream

Source§

fn from(os: OwnedSocket) -> Self

Converts to this type from the input type.
Source§

impl From<WindowsUnixStream> for OwnedSocket

Source§

fn from(value: WindowsUnixStream) -> Self

Converts to this type from the input type.
Source§

impl FromRawSocket for WindowsUnixStream

Source§

unsafe fn from_raw_socket(sock: RawSocket) -> Self

Constructs a new I/O object from the specified raw socket. Read more
Source§

impl IntoRawSocket for WindowsUnixStream

Source§

fn into_raw_socket(self) -> RawSocket

Consumes this object, returning the raw underlying socket. Read more
Source§

impl Read for WindowsUnixStream

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
Source§

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

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” adapter 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§

fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>
where Self: Sized,

🔬This is a nightly-only experimental API. (read_array)
Read and return a fixed array of bytes from this source. Read more
Source§

impl Write for WindowsUnixStream

Source§

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

Do not access bufs after sending!

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
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
Source§

impl<ESSR: EsInterfaceRegistry> XioEventPipe<ESSR> for WindowsUnixStream

Source§

fn connect_event_pipe( &mut self, ess: &XioRegistry<ESSR>, ev_uid: XioEventUid, channel: XioChannel, ) -> XioResult<()>

Should connect the self to the endpoint which is provided by the argument ess.
Source§

fn modify_event_pipe( &mut self, ess: &XioRegistry<ESSR>, ev_uid: XioEventUid, channel: XioChannel, ) -> XioResult<()>

This interface function should be reimplemented soon. Read more
Source§

fn disconnect_event_pipe(&mut self, ess: &XioRegistry<ESSR>) -> XioResult<()>

Should disconnect self from the ess provided endpoint. An instance which implements the logic should check that the ess matches the ess used when self was initially registered (if available).

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