FromRawHandle in std::os::windows::io - Rust (original) (raw)

Trait FromRawHandle

1.0.0 · Source

pub trait FromRawHandle {
    // Required method
    unsafe fn from_raw_handle(handle: RawHandle) -> Self;
}

Available on Windows only.

Expand description

Constructs I/O objects from raw handles.

1.1.0 · Source

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 aFrom<OwnedHandle>::from implementation for an API which strictly consumes ownership.

§Safety

The handle passed in must:

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.

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

1.1.0 · Source§

1.2.0 · Source§

1.63.0 · Source§