Skip to main content

FromRawFd

Trait FromRawFd 

Source
pub trait FromRawFd {
    type Metadata: Default;

    // Required method
    unsafe fn from_raw_fd(fd: RawFd, metadata: Self::Metadata) -> Self;
}
🔬This is a nightly-only experimental API. (sgx_platform #56975)
Available on Fortanix and SGX only.
Expand description

A trait to express the ability to construct an object from a raw file descriptor.

Required Associated Types§

Source

type Metadata: Default

🔬This is a nightly-only experimental API. (sgx_platform #56975)

An associated type that contains relevant metadata for Self.

Required Methods§

Source

unsafe fn from_raw_fd(fd: RawFd, metadata: Self::Metadata) -> Self

🔬This is a nightly-only experimental API. (sgx_platform #56975)

Constructs a new instance of Self from the given raw file descriptor and metadata.

This function is typically used to consume ownership of the specified file descriptor. 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<OwnedFd>::from implementation for an API which strictly consumes ownership.

§Safety

The fd passed in must be an owned file descriptor; in particular, it must be open.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§