Struct std::os::windows::io::OwnedHandle
#[repr(transparent)]pub struct OwnedHandle { /* fields omitted */ }
An owned handle.
This closes the handle on drop.
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 a consumed argument or returned as an owned value, and is never null.
Note that it may have the value INVALID_HANDLE_VALUE
(-1), which is sometimes a valid handle value. See here for the full story. For APIs like CreateFileW
which report errors with INVALID_HANDLE_VALUE
instead of null, use HandleOrInvalid
instead of Option<OwnedHandle>
.
OwnedHandle
uses CloseHandle
to close its handle on drop. As such, it must not be used with handles to open registry keys which need to be closed with RegCloseKey
instead.
Trait Implementations
impl AsHandle for OwnedHandle
impl AsRawHandle for OwnedHandle
fn as_raw_handle(&self) -> RawHandle
Extracts the raw handle, without taking any ownership.
impl Debug for OwnedHandle
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the value using the given formatter. Read more
impl Drop for OwnedHandle
impl From<Child> for OwnedHandle
fn from(child: Child) -> OwnedHandle
Performs the conversion.
impl From<ChildStderr> for OwnedHandle
fn from(child_stderr: ChildStderr) -> OwnedHandle
Performs the conversion.
impl From<ChildStdin> for OwnedHandle
fn from(child_stdin: ChildStdin) -> OwnedHandle
Performs the conversion.
impl From<ChildStdout> for OwnedHandle
fn from(child_stdout: ChildStdout) -> OwnedHandle
Performs the conversion.
impl From<File> for OwnedHandle
fn from(file: File) -> OwnedHandle
Performs the conversion.
impl<T> From<JoinHandle<T>> for OwnedHandle
fn from(join_handle: JoinHandle<T>) -> OwnedHandle
Performs the conversion.
impl From<OwnedHandle> for File
fn from(owned: OwnedHandle) -> Self
Performs the conversion.
impl From<OwnedHandle> for Stdio
fn from(handle: OwnedHandle) -> Stdio
Performs the conversion.
impl FromRawHandle for OwnedHandle
unsafe fn from_raw_handle(handle: RawHandle) -> Self
Constructs a new instance of Self
from the given raw handle.
Use HandleOrInvalid
instead of Option<OwnedHandle>
for APIs that use INVALID_HANDLE_VALUE
to indicate failure.
Safety
The resource pointed to by handle
must be open and suitable for assuming ownership. The resource must not require any cleanup other than CloseHandle
.
In particular, it must not be used with handles to open registry keys which need to be closed with RegCloseKey
instead.
Note that it may have the value INVALID_HANDLE_VALUE
(-1), which is sometimes a valid handle value. See here for the full story.
impl IntoRawHandle for OwnedHandle
fn into_raw_handle(self) -> RawHandle
Consumes this object, returning the raw underlying handle. Read more
impl TryFrom<HandleOrInvalid> for OwnedHandle
type Error = ()
The type returned in the event of a conversion error.
fn try_from(handle_or_invalid: HandleOrInvalid) -> Result<Self, ()>
Performs the conversion.
impl Send for OwnedHandle
impl Sync for OwnedHandle
Auto Trait Implementations
impl RefUnwindSafe for OwnedHandle
impl Unpin for OwnedHandle
impl UnwindSafe for OwnedHandle
Blanket Implementations
impl<T> From<T> for T
pub fn from(t: T) -> T
Performs the conversion.
pub fn into(self) -> U
Performs the conversion.
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
Performs the conversion.
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
Performs the conversion.
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/windows/io/struct.OwnedHandle.html