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
OwnedFdinstance that shares the same underlying file description as the existingOwnedFdinstance.
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) -> OwnedFdTakes ownership of a
TcpListener's socket file descriptor.
impl From for OwnedFd
fn from(udp_socket: crate::net::UdpSocket) -> OwnedFdTakes 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) -> OwnedFdTakes 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) -> OwnedFdTakes 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) -> OwnedFdTakes ownership of a
ChildStdout's file descriptor.
impl From for crate::os::unix::io::OwnedFd
fn from(listener: UnixListener) -> OwnedFdTakes ownership of a
UnixListener's socket file descriptor.
impl From for crate::os::unix::io::OwnedFd
fn from(child_stderr: crate::process::ChildStderr) -> OwnedFdTakes ownership of a
ChildStderr's file descriptor.
impl From for crate::os::unix::io::OwnedFd
fn from(unix_datagram: UnixDatagram) -> OwnedFdTakes 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) -> OwnedFdTakes ownership of a
ChildStdin's file descriptor.
impl From for crate::os::unix::io::OwnedFd
fn from(unix_stream: UnixStream) -> OwnedFdTakes ownership of a
UnixStream's socket file descriptor.
impl FromRawFd for OwnedFd
unsafe fn from_raw_fd(fd: RawFd) -> SelfConstructs a new instance of
Selffrom the given raw file descriptor.Safety
The resource pointed to by
fdmust be open and suitable for assuming ownership. The resource must not require any cleanup other thanclose.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) -> TReturns the argument unchanged.
impl<T, U> Into for OwnedFd
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses 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>