Struct OwnedHandle

1.63.0 ยท Source
pub struct OwnedHandle { /* private fields */ }
Available on Windows only.
Expand description

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.

Implementationsยง

Sourceยง

impl OwnedHandle

1.63.0 ยท Source

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

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

Trait Implementationsยง

1.63.0 ยท Sourceยง

impl AsHandle for OwnedHandle

Sourceยง

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

Borrows the handle. Read more
1.63.0 ยท Sourceยง

impl AsRawHandle for OwnedHandle

Sourceยง

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
1.63.0 ยท Sourceยง

impl Debug for OwnedHandle

Sourceยง

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

Formats the value using the given formatter. Read more
1.63.0 ยท Sourceยง

impl Drop for OwnedHandle

Sourceยง

fn drop(&mut self)

Executes the destructor for this type. Read more
1.63.0 ยท Sourceยง

impl From<Child> for OwnedHandle

Sourceยง

fn from(child: Child) -> OwnedHandle

Takes ownership of a Childโ€™s process handle.

1.63.0 ยท Sourceยง

impl From<ChildStderr> for OwnedHandle

Sourceยง

fn from(child_stderr: ChildStderr) -> OwnedHandle

Takes ownership of a ChildStderrโ€™s file handle.

1.63.0 ยท Sourceยง

impl From<ChildStdin> for OwnedHandle

Sourceยง

fn from(child_stdin: ChildStdin) -> OwnedHandle

Takes ownership of a ChildStdinโ€™s file handle.

1.63.0 ยท Sourceยง

impl From<ChildStdout> for OwnedHandle

Sourceยง

fn from(child_stdout: ChildStdout) -> OwnedHandle

Takes ownership of a ChildStdoutโ€™s file handle.

1.63.0 ยท Sourceยง

impl From<File> for OwnedHandle

Sourceยง

fn from(file: File) -> OwnedHandle

Takes ownership of a Fileโ€™s underlying file handle.

1.63.0 ยท Sourceยง

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

Sourceยง

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

Converts to this type from the input type.
1.74.0 ยท Sourceยง

impl From<OwnedHandle> for ChildStderr

Creates a ChildStderr from the provided OwnedHandle.

The provided handle must be asynchronous, as reading and writing from and to it is implemented using asynchronous APIs.

Sourceยง

fn from(handle: OwnedHandle) -> ChildStderr โ“˜

Converts to this type from the input type.
1.74.0 ยท Sourceยง

impl From<OwnedHandle> for ChildStdin

Creates a ChildStdin from the provided OwnedHandle.

The provided handle must be asynchronous, as reading and writing from and to it is implemented using asynchronous APIs.

Sourceยง

fn from(handle: OwnedHandle) -> ChildStdin โ“˜

Converts to this type from the input type.
1.74.0 ยท Sourceยง

impl From<OwnedHandle> for ChildStdout

Creates a ChildStdout from the provided OwnedHandle.

The provided handle must be asynchronous, as reading and writing from and to it is implemented using asynchronous APIs.

Sourceยง

fn from(handle: OwnedHandle) -> ChildStdout โ“˜

Converts to this type from the input type.
1.63.0 ยท Sourceยง

impl From<OwnedHandle> for File

Sourceยง

fn from(owned: OwnedHandle) -> Self

Returns a File that takes ownership of the given handle.

1.87.0 ยท Sourceยง

impl From<OwnedHandle> for PipeReader

Sourceยง

fn from(owned_handle: OwnedHandle) -> Self

Converts to this type from the input type.
1.87.0 ยท Sourceยง

impl From<OwnedHandle> for PipeWriter

Sourceยง

fn from(owned_handle: OwnedHandle) -> Self

Converts to this type from the input type.
1.63.0 ยท Sourceยง

impl From<OwnedHandle> for Stdio

Sourceยง

fn from(handle: OwnedHandle) -> Stdio

Takes ownership of a handle and returns a Stdio that can attach a stream to it.

1.87.0 ยท Sourceยง

impl From<PipeReader> for OwnedHandle

Sourceยง

fn from(pipe: PipeReader) -> Self

Converts to this type from the input type.
1.87.0 ยท Sourceยง

impl From<PipeWriter> for OwnedHandle

Sourceยง

fn from(pipe: PipeWriter) -> Self

Converts to this type from the input type.
1.63.0 ยท Sourceยง

impl FromRawHandle for OwnedHandle

Sourceยง

unsafe fn from_raw_handle(handle: RawHandle) -> Self

Constructs a new I/O object from the specified raw handle. Read more
1.63.0 ยท Sourceยง

impl IntoRawHandle for OwnedHandle

Sourceยง

fn into_raw_handle(self) -> RawHandle

Consumes this object, returning the raw underlying handle. Read more
1.70.0 ยท Sourceยง

impl IsTerminal for OwnedHandle

Sourceยง

fn is_terminal(&self) -> bool

Returns true if the descriptor/handle refers to a terminal/tty. Read more
1.63.0 ยท Sourceยง

impl TryFrom<HandleOrInvalid> for OwnedHandle

Sourceยง

type Error = InvalidHandleError

The type returned in the event of a conversion error.
Sourceยง

fn try_from( handle_or_invalid: HandleOrInvalid, ) -> Result<Self, InvalidHandleError>

Performs the conversion.
1.63.0 ยท Sourceยง

impl TryFrom<HandleOrNull> for OwnedHandle

Sourceยง

type Error = NullHandleError

The type returned in the event of a conversion error.
Sourceยง

fn try_from(handle_or_null: HandleOrNull) -> Result<Self, NullHandleError>

Performs the conversion.
1.63.0 ยท Sourceยง

impl Send for OwnedHandle

1.63.0 ยท Sourceยง

impl Sync for OwnedHandle

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

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

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

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

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

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

Sourceยง

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

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

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

Sourceยง

fn into(self) -> U

Calls U::from(self).

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

Sourceยง

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

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.
Sourceยง

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

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

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

Performs the conversion.