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

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

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

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

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

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

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

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 RawReadable are decoded into UTF-8.

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 RawWriteable are encoded from UTF-8.

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 RawWriteable are encoded from UTF-8.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Extracts the raw grip.

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.