Skip to main content

FromRawFd

Trait FromRawFd 

1.1.0 · Source
pub trait FromRawFd {
    // Required method
    unsafe fn from_raw_handle(handle: *mut c_void) -> Self;
}
Expand description

Constructs I/O objects from raw handles.

Required Methods§

1.1.0 · Source

unsafe fn from_raw_handle(handle: *mut c_void) -> 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 an owned handle; in particular, it must be open.
  • 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.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl FromRawHandle for NamedPipeClient

Available on Windows only.
Source§

impl FromRawHandle for NamedPipeServer

Available on Windows only.
Source§

impl FromRawHandle for compio::fs::File

Available on Windows only.
Source§

impl FromRawHandle for Dir

1.1.0 · Source§

impl FromRawHandle for std::fs::File

1.87.0 · Source§

impl FromRawHandle for PipeReader

1.87.0 · Source§

impl FromRawHandle for PipeWriter

1.63.0 · Source§

impl FromRawHandle for OwnedHandle

1.2.0 · Source§

impl FromRawHandle for Stdio

§

impl FromRawHandle for Handle

Source§

impl<S> FromRawHandle for Attacher<S>
where S: FromRawHandle,

Available on Windows only.
Source§

impl<T> FromRawHandle for AsyncFd<T>
where T: AsFd + FromRawHandle,

Source§

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

Available on Windows only.