# Struct std::os::wasi::io::OwnedFd
[−][src]

    #[repr(transparent)]pub struct OwnedFd { /* fields omitted */ }

🔬 This is a nightly-only experimental API. (`io_safety` #87074)
This is supported on WASI only.
Expand description

An owned file descriptor.

This closes the file descriptor on drop.

This uses `repr(transparent)` and has the representation of a host file descriptor, so it can be used in FFI in places where a file descriptor is passed as a consumed argument or returned as an owned value, and it never has the value `-1`.

## Trait Implementations

[src]

### impl AsFd for OwnedFd

[src]

#### fn as_fd(&self) -> BorrowedFd<'_>

🔬 This is a nightly-only experimental API. (`io_safety` #87074)
This is supported on Unix only.

Borrows the file descriptor. Read more

[src]

### impl AsRawFd for OwnedFd

[src]

#### fn as_raw_fd(&self) -> RawFd

This is supported on Unix only.

Extracts the raw file descriptor. Read more

[src]

### impl Debug for OwnedFd

[src]

#### fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

[src]

### impl Drop for OwnedFd

[src]

#### fn drop(&mut self)

Executes the destructor for this type. Read more

[src]

### impl From<ChildStderr> for OwnedFd

This is supported on Unix only.
[src]

#### fn from(child_stderr: ChildStderr) -> OwnedFd

Performs the conversion.

[src]

### impl From<ChildStdin> for OwnedFd

This is supported on Unix only.
[src]

#### fn from(child_stdin: ChildStdin) -> OwnedFd

Performs the conversion.

[src]

### impl From<ChildStdout> for OwnedFd

This is supported on Unix only.
[src]

#### fn from(child_stdout: ChildStdout) -> OwnedFd

Performs the conversion.

[src]

### impl From<File> for OwnedFd

[src]

#### fn from(file: File) -> OwnedFd

Performs the conversion.

[src]

### impl From<OwnedFd> for UnixDatagram

This is supported on Unix only.
[src]

#### fn from(owned: OwnedFd) -> Self

Performs the conversion.

[src]

### impl From<OwnedFd> for UnixListener

This is supported on Unix only.
[src]

#### fn from(fd: OwnedFd) -> UnixListener

Performs the conversion.

[src]

### impl From<OwnedFd> for UnixStream

This is supported on Unix only.
[src]

#### fn from(owned: OwnedFd) -> Self

Performs the conversion.

[src]

### impl From<OwnedFd> for Stdio

This is supported on Unix only.
[src]

#### fn from(fd: OwnedFd) -> Stdio

Performs the conversion.

[src]

### impl From<OwnedFd> for PidFd

This is supported on Linux only.
[src]

#### fn from(fd: OwnedFd) -> Self

Performs the conversion.

[src]

### impl From<OwnedFd> for File

[src]

#### fn from(owned_fd: OwnedFd) -> Self

Performs the conversion.

[src]

### impl From<OwnedFd> for TcpStream

[src]

#### fn from(owned_fd: OwnedFd) -> Self

Performs the conversion.

[src]

### impl From<OwnedFd> for TcpListener

[src]

#### fn from(owned_fd: OwnedFd) -> Self

Performs the conversion.

[src]

### impl From<OwnedFd> for UdpSocket

[src]

#### fn from(owned_fd: OwnedFd) -> Self

Performs the conversion.

[src]

### impl From<PidFd> for OwnedFd

This is supported on Linux only.
[src]

#### fn from(pid_fd: PidFd) -> Self

Performs the conversion.

[src]

### impl From<TcpListener> for OwnedFd

[src]

#### fn from(tcp_listener: TcpListener) -> OwnedFd

Performs the conversion.

[src]

### impl From<TcpStream> for OwnedFd

[src]

#### fn from(tcp_stream: TcpStream) -> OwnedFd

Performs the conversion.

[src]

### impl From<UdpSocket> for OwnedFd

[src]

#### fn from(udp_socket: UdpSocket) -> OwnedFd

Performs the conversion.

[src]

### impl From<UnixDatagram> for OwnedFd

This is supported on Unix only.
[src]

#### fn from(unix_datagram: UnixDatagram) -> OwnedFd

Performs the conversion.

[src]

### impl From<UnixListener> for OwnedFd

This is supported on Unix only.
[src]

#### fn from(listener: UnixListener) -> OwnedFd

Performs the conversion.

[src]

### impl From<UnixStream> for OwnedFd

This is supported on Unix only.
[src]

#### fn from(unix_stream: UnixStream) -> OwnedFd

Performs the conversion.

[src]

### impl FromRawFd for OwnedFd

[src]

#### unsafe fn from_raw_fd(fd: RawFd) -> Self

This is supported on Unix only.

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

# Safety

The resource pointed to by `fd` must be open and suitable for assuming ownership. The resource must not require any cleanup other than `close`.

[src]

### impl IntoRawFd for OwnedFd

[src]

#### fn into_raw_fd(self) -> RawFd

This is supported on Unix only.

Consumes this object, returning the raw underlying file descriptor. Read more

## Auto Trait Implementations

### impl RefUnwindSafe for OwnedFd

### impl Send for OwnedFd

### impl Sync for OwnedFd

### impl Unpin for OwnedFd

### impl UnwindSafe for OwnedFd

## Blanket Implementations

[src]

### impl<T> Any for T where
T: 'static + ?Sized,

[src]

#### pub fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more

[src]

### impl<T> Borrow<T> for T where
T: ?Sized,

[src]

#### pub fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

[src]

### impl<T> BorrowMut<T> for T where
T: ?Sized,

[src]

#### pub fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more

[src]

### impl<T> From<T> for T

[src]

#### pub fn from(t: T) -> T

Performs the conversion.

[src]

### impl<T, U> Into<U> for T where
U: From<T>,

[src]

#### pub fn into(self) -> U

Performs the conversion.

[src]

### impl<T, U> TryFrom<U> for T where
U: Into<T>,

#### type Error = Infallible

The type returned in the event of a conversion error.

[src]

#### pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.

[src]

### impl<T, U> TryInto<U> for T where
U: TryFrom<T>,

#### type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

[src]

#### pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.