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
impl OwnedHandle
1.63.0 · Sourcepub fn try_clone(&self) -> Result<OwnedHandle, Error>
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
impl AsHandle for OwnedHandle
Source§fn as_handle(&self) -> BorrowedHandle<'_>
fn as_handle(&self) -> BorrowedHandle<'_>
1.63.0 · Source§impl AsRawHandle for OwnedHandle
impl AsRawHandle for OwnedHandle
1.63.0 · Source§impl Debug for OwnedHandle
impl Debug for OwnedHandle
1.63.0 · Source§impl Drop for OwnedHandle
impl Drop for OwnedHandle
1.63.0 · Source§impl From<Child> for OwnedHandle
impl From<Child> for OwnedHandle
1.63.0 · Source§impl From<ChildStderr> for OwnedHandle
impl From<ChildStderr> for OwnedHandle
Source§fn from(child_stderr: ChildStderr) -> OwnedHandle
fn from(child_stderr: ChildStderr) -> OwnedHandle
Takes ownership of a ChildStderr
’s file handle.
1.63.0 · Source§impl From<ChildStdin> for OwnedHandle
impl From<ChildStdin> for OwnedHandle
Source§fn from(child_stdin: ChildStdin) -> OwnedHandle
fn from(child_stdin: ChildStdin) -> OwnedHandle
Takes ownership of a ChildStdin
’s file handle.
1.63.0 · Source§impl From<ChildStdout> for OwnedHandle
impl From<ChildStdout> for OwnedHandle
Source§fn from(child_stdout: ChildStdout) -> OwnedHandle
fn from(child_stdout: ChildStdout) -> OwnedHandle
Takes ownership of a ChildStdout
’s file handle.
1.63.0 · Source§impl From<File> for OwnedHandle
impl From<File> for OwnedHandle
1.63.0 · Source§impl<T> From<JoinHandle<T>> for OwnedHandle
impl<T> From<JoinHandle<T>> for OwnedHandle
Source§fn from(join_handle: JoinHandle<T>) -> OwnedHandle
fn from(join_handle: JoinHandle<T>) -> OwnedHandle
Source§impl From<PipeReader> for OwnedHandle
impl From<PipeReader> for OwnedHandle
Source§fn from(pipe: PipeReader) -> OwnedHandle
fn from(pipe: PipeReader) -> OwnedHandle
Source§impl From<PipeWriter> for OwnedHandle
impl From<PipeWriter> for OwnedHandle
Source§fn from(pipe: PipeWriter) -> OwnedHandle
fn from(pipe: PipeWriter) -> OwnedHandle
1.63.0 · Source§impl FromRawHandle for OwnedHandle
impl FromRawHandle for OwnedHandle
Source§unsafe fn from_raw_handle(handle: *mut c_void) -> OwnedHandle
unsafe fn from_raw_handle(handle: *mut c_void) -> OwnedHandle
1.63.0 · Source§impl IntoRawHandle for OwnedHandle
impl IntoRawHandle for OwnedHandle
1.70.0 · Source§impl IsTerminal for OwnedHandle
impl IsTerminal for OwnedHandle
Source§fn is_terminal(&self) -> bool
fn is_terminal(&self) -> bool
true
if the descriptor/handle refers to a terminal/tty. Read more1.63.0 · Source§impl TryFrom<HandleOrInvalid> for OwnedHandle
impl TryFrom<HandleOrInvalid> for OwnedHandle
Source§type Error = InvalidHandleError
type Error = InvalidHandleError
Source§fn try_from(
handle_or_invalid: HandleOrInvalid,
) -> Result<OwnedHandle, InvalidHandleError>
fn try_from( handle_or_invalid: HandleOrInvalid, ) -> Result<OwnedHandle, InvalidHandleError>
1.63.0 · Source§impl TryFrom<HandleOrNull> for OwnedHandle
impl TryFrom<HandleOrNull> for OwnedHandle
Source§type Error = NullHandleError
type Error = NullHandleError
Source§fn try_from(
handle_or_null: HandleOrNull,
) -> Result<OwnedHandle, NullHandleError>
fn try_from( handle_or_null: HandleOrNull, ) -> Result<OwnedHandle, NullHandleError>
impl FilelikeViewType for OwnedHandle
impl Send for OwnedHandle
impl Sync for OwnedHandle
Auto Trait Implementations§
impl Freeze for OwnedHandle
impl RefUnwindSafe for OwnedHandle
impl Unpin for OwnedHandle
impl UnwindSafe for OwnedHandle
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 moreSource§impl<T> AsRawFilelike for Twhere
T: AsRawHandle,
impl<T> AsRawFilelike for Twhere
T: AsRawHandle,
Source§fn as_raw_filelike(&self) -> *mut c_void
fn as_raw_filelike(&self) -> *mut c_void
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FromFilelike for Twhere
T: From<OwnedHandle>,
impl<T> FromFilelike for Twhere
T: From<OwnedHandle>,
Source§fn from_filelike(owned: OwnedHandle) -> T
fn from_filelike(owned: OwnedHandle) -> T
Self
from the given filelike object. Read moreSource§fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
Self
from the given filelike object
converted from into_owned
. Read moreSource§impl<T> FromHandle for Twhere
T: From<OwnedHandle>,
impl<T> FromHandle for Twhere
T: From<OwnedHandle>,
Source§fn from_handle(owned_handle: OwnedHandle) -> T
fn from_handle(owned_handle: OwnedHandle) -> T
FromHandle::from_handle
is replaced by From<OwnedHandle>::from
Self
from the given handle. Read moreSource§fn from_into_handle<Owned: Into<OwnedHandle>>(into_owned: Owned) -> Self
fn from_into_handle<Owned: Into<OwnedHandle>>(into_owned: Owned) -> Self
Source§impl<T> FromRawFilelike for Twhere
T: FromRawHandle,
impl<T> FromRawFilelike for Twhere
T: FromRawHandle,
Source§unsafe fn from_raw_filelike(raw: *mut c_void) -> T
unsafe fn from_raw_filelike(raw: *mut c_void) -> T
Self
from the raw value.Source§impl<T> IntoFilelike for Twhere
T: Into<OwnedHandle>,
impl<T> IntoFilelike for Twhere
T: Into<OwnedHandle>,
Source§fn into_filelike(self) -> OwnedHandle
fn into_filelike(self) -> OwnedHandle
Source§impl<T> IntoHandle for Twhere
OwnedHandle: From<T>,
impl<T> IntoHandle for Twhere
OwnedHandle: From<T>,
Source§fn into_handle(self) -> OwnedHandle
fn into_handle(self) -> OwnedHandle
IntoHandle
is replaced by From<...> for OwnedHandle
or Into<OwnedHandle>