Struct OwnedHandle

#[repr(transparent)]
pub struct OwnedHandle { pub(in ::os::windows::io::handle) handle: RawHandle }

An owned handle.

This closes the handle on drop.

Note that it may have the value -1, which in OwnedHandle 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.

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.

Fields

handle: RawHandle

Implementations

impl OwnedHandle

fn try_clone(&self) -> Result<Self>

Creates a new OwnedHandle instance that shares the same underlying object as the existing OwnedHandle instance.

Trait Implementations

impl AsHandle for OwnedHandle

fn as_handle(&self) -> BorrowedHandle<'_>

impl AsRawHandle for OwnedHandle

fn as_raw_handle(&self) -> RawHandle

impl Debug for OwnedHandle

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Drop for OwnedHandle

fn drop(&mut self)

impl From<Child> for OwnedHandle

fn from(child: Child) -> OwnedHandle

Takes ownership of a Child's process handle.

impl From<ChildStderr> for OwnedHandle

fn from(child_stderr: ChildStderr) -> OwnedHandle

Takes ownership of a ChildStderr's file handle.

impl From<ChildStdin> for OwnedHandle

fn from(child_stdin: ChildStdin) -> OwnedHandle

Takes ownership of a ChildStdin's file handle.

impl From<ChildStdout> for OwnedHandle

fn from(child_stdout: ChildStdout) -> OwnedHandle

Takes ownership of a ChildStdout's file handle.

impl From<File> for OwnedHandle

fn from(file: File) -> OwnedHandle

Takes ownership of a File's underlying file handle.

impl From<PipeReader> for OwnedHandle

fn from(pipe: PipeReader) -> Self

impl From<PipeWriter> for OwnedHandle

fn from(pipe: PipeWriter) -> Self

impl FromRawHandle for OwnedHandle

unsafe fn from_raw_handle(handle: RawHandle) -> Self

impl IntoRawHandle for OwnedHandle

fn into_raw_handle(self) -> RawHandle

impl IsTerminal for OwnedHandle

fn is_terminal(&self) -> bool

impl Send for OwnedHandle

impl Sync for OwnedHandle

impl TryFrom<HandleOrInvalid> for OwnedHandle

type Error = InvalidHandleError;
fn try_from(handle_or_invalid: HandleOrInvalid) -> Result<Self, InvalidHandleError>

impl TryFrom<HandleOrNull> for OwnedHandle

type Error = NullHandleError;
fn try_from(handle_or_null: HandleOrNull) -> Result<Self, NullHandleError>

impl<T> From<JoinHandle<T>> for OwnedHandle

fn from(join_handle: JoinHandle<T>) -> OwnedHandle

Auto Trait Implementations

impl Freeze for OwnedHandle

impl RefUnwindSafe for OwnedHandle

impl Unpin for OwnedHandle

impl UnsafeUnpin for OwnedHandle

impl UnwindSafe for OwnedHandle

Blanket Implementations

impl<T> Any for OwnedHandle where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for OwnedHandle where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for OwnedHandle where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for OwnedHandle

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for OwnedHandle where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for OwnedHandle

impl<T, U> Into<U> for OwnedHandle where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for OwnedHandle where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for OwnedHandle where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>