Struct unsafe_io::os::windows::RawHandleOrSocket[][src]

#[repr(transparent)]pub struct RawHandleOrSocket(_);

A Windows analog for the Posix-ish AsRawFd type. Unlike Posix-ish platforms which have a single type for files and sockets, Windows has distinct types, RawHandle and RawSocket. And unlike Posix-ish platforms where text streams are generally UTF-8, the Windows Console is UTF-16. This type behaves like an enum which can hold either a handle or a socket, and to which UTF-8 text can be written.

It’s reasonable to worry that this might be trying too hard to make Windows work like Posix-ish platforms, however in this case, the number of types is small, so the enum is simple and the overhead is relatively low, and the benefit is that we can abstract over major Read and Write resources.

Implementations

impl RawHandleOrSocket[src]

#[must_use]pub const fn unowned_from_raw_handle(raw_handle: RawHandle) -> Self[src]

Like FromRawHandle::from_raw_handle, but isn’t unsafe because it doesn’t imply a dereference.

#[must_use]pub const fn unowned_from_raw_socket(raw_socket: RawSocket) -> Self[src]

Like FromRawSocket::from_raw_socket, but isn’t unsafe because it doesn’t imply a dereference.

#[must_use]pub fn as_unowned_raw_handle(&self) -> Option<RawHandle>[src]

Like AsRawHandle::as_raw_handle, but returns an Option so that it can return None if self doesn’t contain a RawHandle.

#[must_use]pub const fn as_unowned_raw_socket(&self) -> Option<RawSocket>[src]

Like AsRawSocket::as_raw_socket, but returns an Option so that it can return None if self doesn’t contain a RawSocket.

#[must_use]pub const fn stdin() -> Self[src]

Return a RawHandleOrSocket representing stdin.

This differs from unowned_from_raw_handle on the stdin handle in two ways:

  • It tracks the stdin handle, which may change dynamically via SetStdHandle.
  • When stdin is attached to a console, reads from this handle via UnsafeReadable are decoded into UTF-8.

#[must_use]pub const fn stdout() -> Self[src]

Return a RawHandleOrSocket representing stdout.

This differs from unowned_from_raw_handle on the stdout handle in two ways:

  • It tracks the stdout handle, which may change dynamically via SetStdHandle.
  • When stdout is attached to a console, writes to this handle via UnsafeWriteable are encoded from UTF-8.

#[must_use]pub const fn stderr() -> Self[src]

Return a RawHandleOrSocket representing stderr.

This differs from unowned_from_raw_handle on the stderr handle in two ways:

  • It tracks the stderr handle, which may change dynamically via SetStdHandle.
  • When stderr is attached to a console, writes to this handle via UnsafeWriteable are encoded from UTF-8.

Trait Implementations

impl AsRawHandleOrSocket for RawHandleOrSocket[src]

impl Clone for RawHandleOrSocket[src]

impl Copy for RawHandleOrSocket[src]

impl Debug for RawHandleOrSocket[src]

impl Eq for RawHandleOrSocket[src]

impl Hash for RawHandleOrSocket[src]

impl Ord for RawHandleOrSocket[src]

impl PartialEq<RawHandleOrSocket> for RawHandleOrSocket[src]

impl PartialOrd<RawHandleOrSocket> for RawHandleOrSocket[src]

impl Send for RawHandleOrSocket[src]

The Windows HANDLE and SOCKET types may be sent between threads.

impl StructuralEq for RawHandleOrSocket[src]

impl StructuralPartialEq for RawHandleOrSocket[src]

impl Sync for RawHandleOrSocket[src]

The Windows HANDLE and SOCKET types may be shared between threads.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.