pub struct BorrowedHandle<'handle> { /* private fields */ }
Expand description
A borrowed handle.
This has a lifetime parameter to tie it to the lifetime of something that owns the handle.
This uses repr(transparent)
and has the representation of a host handle,
so it can be used in FFI in places where a handle is passed as an argument,
it is not captured or consumed.
Note that it may have the value -1
, which in BorrowedHandle
always
represents a valid handle value, such as the current process handle, and
not INVALID_HANDLE_VALUE
, despite the two having the same value. See
here for the full story.
And, it may have the value NULL
(0), which can occur when consoles are
detached from processes, or when windows_subsystem
is used.
This type’s .to_owned()
implementation returns another BorrowedHandle
rather than an OwnedHandle
. It just makes a trivial copy of the raw
handle, which is then borrowed under the same lifetime.
Implementations§
Source§impl BorrowedHandle<'_>
impl BorrowedHandle<'_>
1.63.0 (const: 1.63.0) · Sourcepub const unsafe fn borrow_raw(handle: *mut c_void) -> BorrowedHandle<'_>
pub const unsafe fn borrow_raw(handle: *mut c_void) -> BorrowedHandle<'_>
Returns a BorrowedHandle
holding the given raw handle.
§Safety
The resource pointed to by handle
must be a valid open handle, it
must remain open for the duration of the returned BorrowedHandle
.
Note that it may have the value INVALID_HANDLE_VALUE
(-1), which is
sometimes a valid handle value. See here for the full story.
And, it may have the value NULL
(0), which can occur when consoles are
detached from processes, or when windows_subsystem
is used.
Source§impl BorrowedHandle<'_>
impl BorrowedHandle<'_>
1.63.0 · Sourcepub fn try_clone_to_owned(&self) -> Result<OwnedHandle, Error>
pub fn try_clone_to_owned(&self) -> Result<OwnedHandle, Error>
Creates a new OwnedHandle
instance that shares the same underlying
object as the existing BorrowedHandle
instance.
Trait Implementations§
1.63.0 · Source§impl AsHandle for BorrowedHandle<'_>
impl AsHandle for BorrowedHandle<'_>
Source§fn as_handle(&self) -> BorrowedHandle<'_>
fn as_handle(&self) -> BorrowedHandle<'_>
1.63.0 · Source§impl AsRawHandle for BorrowedHandle<'_>
impl AsRawHandle for BorrowedHandle<'_>
1.63.0 · Source§impl<'handle> Clone for BorrowedHandle<'handle>
impl<'handle> Clone for BorrowedHandle<'handle>
Source§fn clone(&self) -> BorrowedHandle<'handle>
fn clone(&self) -> BorrowedHandle<'handle>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more1.63.0 · Source§impl Debug for BorrowedHandle<'_>
impl Debug for BorrowedHandle<'_>
1.70.0 · Source§impl IsTerminal for BorrowedHandle<'_>
impl IsTerminal for BorrowedHandle<'_>
Source§fn is_terminal(&self) -> bool
fn is_terminal(&self) -> bool
true
if the descriptor/handle refers to a terminal/tty. Read moreimpl<'handle> Copy for BorrowedHandle<'handle>
impl Send for BorrowedHandle<'_>
impl Sync for BorrowedHandle<'_>
Auto Trait Implementations§
impl<'handle> Freeze for BorrowedHandle<'handle>
impl<'handle> RefUnwindSafe for BorrowedHandle<'handle>
impl<'handle> Unpin for BorrowedHandle<'handle>
impl<'handle> UnwindSafe for BorrowedHandle<'handle>
Blanket Implementations§
Source§impl<T> AsFilelike for Twhere
T: AsHandle,
impl<T> AsFilelike for Twhere
T: AsHandle,
Source§fn as_filelike(&self) -> BorrowedHandle<'_>
fn as_filelike(&self) -> BorrowedHandle<'_>
Source§fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target>where
Target: FilelikeViewType,
fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target>where
Target: FilelikeViewType,
&Target
. Read more