Trait std::os::windows::io::FromRawHandle

1.1.0 · source ·
pub trait FromRawHandle {
    // Required method
    unsafe fn from_raw_handle(handle: RawHandle) -> Self;
}
Available on Windows only.
Expand description

Construct I/O objects from raw handles.

Required Methods§

source

unsafe fn from_raw_handle(handle: RawHandle) -> Self

Constructs a new I/O object from the specified raw handle.

This function is typically used to consume ownership of the handle given, passing responsibility for closing the handle to the returned object. When used in this way, the returned object will take responsibility for closing it when the object goes out of scope.

However, consuming ownership is not strictly required. Use a From<OwnedHandle>::from implementation for an API which strictly consumes ownership.

Safety

The handle passed in must:

  • be a valid an open handle,
  • be a handle for a resource that may be freed via CloseHandle (as opposed to RegCloseKey or other close functions).

Note that the handle may have the value INVALID_HANDLE_VALUE (-1), which is sometimes a valid handle value. See here for the full story.

Implementors§

source§

impl FromRawHandle for std::fs::File

1.2.0 · source§

impl FromRawHandle for Stdio

source§

impl FromRawHandle for std::sys::windows::fs::File

source§

impl FromRawHandle for Handle

1.63.0 · source§

impl FromRawHandle for OwnedHandle