pub struct RawHandleOrSocket(/* private fields */);
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§
Source§impl RawHandleOrSocket
impl RawHandleOrSocket
Sourcepub const fn unowned_from_raw_handle(raw_handle: RawHandle) -> Self
pub const fn unowned_from_raw_handle(raw_handle: RawHandle) -> Self
Like FromRawHandle::from_raw_handle
, but isn’t unsafe because it
doesn’t imply a dereference.
Sourcepub const fn unowned_from_raw_socket(raw_socket: RawSocket) -> Self
pub const fn unowned_from_raw_socket(raw_socket: RawSocket) -> Self
Like FromRawSocket::from_raw_socket
, but isn’t unsafe because it
doesn’t imply a dereference.
Sourcepub fn as_raw_handle(&self) -> Option<RawHandle>
pub fn as_raw_handle(&self) -> Option<RawHandle>
Like AsRawHandle::as_raw_handle
, but returns an Option
so that
it can return None
if self
doesn’t contain a RawHandle
.
Sourcepub const fn as_raw_socket(&self) -> Option<RawSocket>
pub const fn as_raw_socket(&self) -> Option<RawSocket>
Like AsRawSocket::as_raw_socket
, but returns an Option
so that
it can return None
if self
doesn’t contain a RawSocket
.
Sourcepub const fn stdin() -> Self
pub const fn stdin() -> Self
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.
Sourcepub const fn stdout() -> Self
pub const fn stdout() -> Self
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.
Sourcepub const fn stderr() -> Self
pub const fn stderr() -> Self
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§
Source§impl AsRawHandleOrSocket for RawHandleOrSocket
impl AsRawHandleOrSocket for RawHandleOrSocket
Source§fn as_raw_handle_or_socket(&self) -> Self
fn as_raw_handle_or_socket(&self) -> Self
AsRawHandle::as_raw_handle
and AsRawSocket::as_raw_socket
but can return either type.Source§impl Clone for RawHandleOrSocket
impl Clone for RawHandleOrSocket
Source§fn clone(&self) -> RawHandleOrSocket
fn clone(&self) -> RawHandleOrSocket
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RawHandleOrSocket
impl Debug for RawHandleOrSocket
Source§impl Hash for RawHandleOrSocket
impl Hash for RawHandleOrSocket
Source§impl Ord for RawHandleOrSocket
impl Ord for RawHandleOrSocket
Source§fn cmp(&self, other: &RawHandleOrSocket) -> Ordering
fn cmp(&self, other: &RawHandleOrSocket) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RawHandleOrSocket
impl PartialEq for RawHandleOrSocket
Source§impl PartialOrd for RawHandleOrSocket
impl PartialOrd for RawHandleOrSocket
impl Copy for RawHandleOrSocket
impl Eq for RawHandleOrSocket
impl Send for RawHandleOrSocket
impl StructuralPartialEq for RawHandleOrSocket
impl Sync for RawHandleOrSocket
Auto Trait Implementations§
impl Freeze for RawHandleOrSocket
impl RefUnwindSafe for RawHandleOrSocket
impl Unpin for RawHandleOrSocket
impl UnwindSafe for RawHandleOrSocket
Blanket Implementations§
Source§impl<T> AsRawGrip for Twhere
T: AsRawHandleOrSocket,
impl<T> AsRawGrip for Twhere
T: AsRawHandleOrSocket,
Source§fn as_raw_grip(&self) -> RawHandleOrSocket
fn as_raw_grip(&self) -> RawHandleOrSocket
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)