io_lifetimes

Struct OwnedHandle

1.63.0 · Source
pub struct OwnedHandle { /* private fields */ }
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<OwnedHandle, Error>

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) -> *mut c_void

Extracts the raw handle. Read more
1.63.0 · Source§

impl Debug for OwnedHandle

Source§

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

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.
Source§

impl From<PipeReader> for OwnedHandle

Source§

fn from(pipe: PipeReader) -> OwnedHandle

Converts to this type from the input type.
Source§

impl From<PipeWriter> for OwnedHandle

Source§

fn from(pipe: PipeWriter) -> OwnedHandle

Converts to this type from the input type.
1.63.0 · Source§

impl FromRawHandle for OwnedHandle

Source§

unsafe fn from_raw_handle(handle: *mut c_void) -> OwnedHandle

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) -> *mut c_void

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<OwnedHandle, 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<OwnedHandle, NullHandleError>

Performs the conversion.
Source§

impl FilelikeViewType for OwnedHandle

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> AsFilelike for T
where T: AsHandle,

Source§

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

Borrows the reference. Read more
Source§

fn as_filelike_view<Target>(&self) -> FilelikeView<'_, Target>
where Target: FilelikeViewType,

Return a borrowing view of a resource which dereferences to a &Target. Read more
Source§

impl<T> AsRawFilelike for T
where T: AsRawHandle,

Source§

fn as_raw_filelike(&self) -> *mut c_void

Returns the raw value.
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> FromFilelike for T
where T: From<OwnedHandle>,

Source§

fn from_filelike(owned: OwnedHandle) -> T

Constructs a new instance of Self from the given filelike object. Read more
Source§

fn from_into_filelike<Owned>(owned: Owned) -> T
where Owned: IntoFilelike,

Constructs a new instance of Self from the given filelike object converted from into_owned. Read more
Source§

impl<T> FromHandle for T
where T: From<OwnedHandle>,

Source§

fn from_handle(owned_handle: OwnedHandle) -> T

👎Deprecated since 1.0.0: FromHandle::from_handle is replaced by From<OwnedHandle>::from
Constructs a new instance of Self from the given handle. Read more
Source§

fn from_into_handle<Owned: Into<OwnedHandle>>(into_owned: Owned) -> Self
where Self: Sized + From<OwnedHandle>,

Constructs a new instance of Self from the given handle converted from into_owned. Read more
Source§

impl<T> FromRawFilelike for T
where T: FromRawHandle,

Source§

unsafe fn from_raw_filelike(raw: *mut c_void) -> T

Constructs Self from the raw value.
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> IntoFilelike for T
where T: Into<OwnedHandle>,

Source§

fn into_filelike(self) -> OwnedHandle

Consumes this object, returning the underlying filelike object.
Source§

impl<T> IntoHandle for T
where OwnedHandle: From<T>,

Source§

fn into_handle(self) -> OwnedHandle

👎Deprecated since 1.0.0: IntoHandle is replaced by From<...> for OwnedHandle or Into<OwnedHandle>
Consumes this object, returning the underlying handle. Read more
Source§

impl<T> IntoRawFilelike for T
where T: IntoRawHandle,

Source§

fn into_raw_filelike(self) -> *mut c_void

Returns the raw value.
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.