Struct OwnedFd

struct OwnedFd { ... }

An owned file descriptor.

This closes the file descriptor on drop. It is guaranteed that nobody else will close the file descriptor.

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.

You can use AsFd::as_fd to obtain a BorrowedFd.

Implementations

impl OwnedFd

fn try_clone(self: &Self) -> io::Result<Self>

Creates a new OwnedFd instance that shares the same underlying file description as the existing OwnedFd instance.

impl AsFd for OwnedFd

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

impl AsRawFd for OwnedFd

fn as_raw_fd(self: &Self) -> RawFd

impl Debug for OwnedFd

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

impl Drop for OwnedFd

fn drop(self: &mut Self)

impl Freeze for OwnedFd

impl From for OwnedFd

fn from(tcp_listener: crate::net::TcpListener) -> OwnedFd

Takes ownership of a TcpListener's socket file descriptor.

impl From for OwnedFd

fn from(udp_socket: crate::net::UdpSocket) -> OwnedFd

Takes ownership of a UdpSocket's file descriptor.

impl From for OwnedFd

fn from(pipe: io::PipeReader) -> Self

impl From for OwnedFd

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

Takes ownership of a File's underlying file descriptor.

impl From for OwnedFd

fn from(pipe: io::PipeWriter) -> Self

impl From for OwnedFd

fn from(tcp_stream: crate::net::TcpStream) -> OwnedFd

Takes ownership of a TcpStream's socket file descriptor.

impl From for crate::os::fd::OwnedFd

fn from(value: fs::Dir) -> Self

impl From for crate::os::unix::io::OwnedFd

fn from(child_stdout: crate::process::ChildStdout) -> OwnedFd

Takes ownership of a ChildStdout's file descriptor.

impl From for crate::os::unix::io::OwnedFd

fn from(listener: UnixListener) -> OwnedFd

Takes ownership of a UnixListener's socket file descriptor.

impl From for crate::os::unix::io::OwnedFd

fn from(child_stderr: crate::process::ChildStderr) -> OwnedFd

Takes ownership of a ChildStderr's file descriptor.

impl From for crate::os::unix::io::OwnedFd

fn from(unix_datagram: UnixDatagram) -> OwnedFd

Takes ownership of a UnixDatagram's socket file descriptor.

impl From for crate::os::unix::io::OwnedFd

fn from(pid_fd: PidFd) -> Self

impl From for crate::os::unix::io::OwnedFd

fn from(child_stdin: crate::process::ChildStdin) -> OwnedFd

Takes ownership of a ChildStdin's file descriptor.

impl From for crate::os::unix::io::OwnedFd

fn from(unix_stream: UnixStream) -> OwnedFd

Takes ownership of a UnixStream's socket file descriptor.

impl FromRawFd for OwnedFd

unsafe fn from_raw_fd(fd: RawFd) -> Self

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.

Panics

Panics if the raw file descriptor has the value -1.

impl IntoRawFd for OwnedFd

fn into_raw_fd(self: Self) -> RawFd

impl IsTerminal for OwnedFd

fn is_terminal(self: &Self) -> bool

impl RefUnwindSafe for OwnedFd

impl Send for OwnedFd

impl Sync for OwnedFd

impl Unpin for OwnedFd

impl UnwindSafe for OwnedFd

impl<T> Any for OwnedFd

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for OwnedFd

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for OwnedFd

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for OwnedFd

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for OwnedFd

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for OwnedFd

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

impl<T, U> TryInto for OwnedFd

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