On this page
Struct std::os::fd::OwnedFd
pub struct OwnedFd { /* private fields */ }
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
.
Implementations
impl OwnedFd
pub fn try_clone(&self) -> Result<Self>
Creates a new OwnedFd
instance that shares the same underlying file description as the existing OwnedFd
instance.
Trait Implementations
impl AsFd for OwnedFd
impl AsRawFd for OwnedFd
impl Debug for OwnedFd
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Drop for OwnedFd
impl From<ChildStderr> for OwnedFdAvailable on Unix only.
fn from(child_stderr: ChildStderr) -> OwnedFd
impl From<ChildStdin> for OwnedFdAvailable on Unix only.
fn from(child_stdin: ChildStdin) -> OwnedFd
impl From<ChildStdout> for OwnedFdAvailable on Unix only.
fn from(child_stdout: ChildStdout) -> OwnedFd
impl From<File> for OwnedFd
fn from(file: File) -> OwnedFd
impl From<OwnedFd> for ChildStderrAvailable on Unix only.
Create a ChildStderr
from the provided OwnedFd
.
The provided file descriptor must point to a pipe with the CLOEXEC
flag set.
fn from(fd: OwnedFd) -> ChildStderr ⓘ
impl From<OwnedFd> for ChildStdinAvailable on Unix only.
Create a ChildStdin
from the provided OwnedFd
.
The provided file descriptor must point to a pipe with the CLOEXEC
flag set.
fn from(fd: OwnedFd) -> ChildStdin ⓘ
impl From<OwnedFd> for ChildStdoutAvailable on Unix only.
Create a ChildStdout
from the provided OwnedFd
.
The provided file descriptor must point to a pipe with the CLOEXEC
flag set.
fn from(fd: OwnedFd) -> ChildStdout ⓘ
impl From<OwnedFd> for File
fn from(owned_fd: OwnedFd) -> Self
impl From<OwnedFd> for PidFdAvailable on Linux only.
fn from(fd: OwnedFd) -> Self
impl From<OwnedFd> for StdioAvailable on Unix only.
fn from(fd: OwnedFd) -> Stdio
impl From<OwnedFd> for TcpListener
fn from(owned_fd: OwnedFd) -> Self
impl From<OwnedFd> for TcpStream
fn from(owned_fd: OwnedFd) -> Self
impl From<OwnedFd> for UdpSocket
fn from(owned_fd: OwnedFd) -> Self
impl From<OwnedFd> for UnixDatagramAvailable on Unix only.
fn from(owned: OwnedFd) -> Self
impl From<OwnedFd> for UnixListenerAvailable on Unix only.
fn from(fd: OwnedFd) -> UnixListener
impl From<OwnedFd> for UnixStreamAvailable on Unix only.
fn from(owned: OwnedFd) -> Self
impl From<PidFd> for OwnedFdAvailable on Linux only.
fn from(pid_fd: PidFd) -> Self
impl From<TcpListener> for OwnedFd
fn from(tcp_listener: TcpListener) -> OwnedFd
impl From<TcpStream> for OwnedFd
fn from(tcp_stream: TcpStream) -> OwnedFd
impl From<UdpSocket> for OwnedFd
fn from(udp_socket: UdpSocket) -> OwnedFd
impl From<UnixDatagram> for OwnedFdAvailable on Unix only.
fn from(unix_datagram: UnixDatagram) -> OwnedFd
impl From<UnixListener> for OwnedFdAvailable on Unix only.
fn from(listener: UnixListener) -> OwnedFd
impl From<UnixStream> for OwnedFdAvailable on Unix only.
fn from(unix_stream: UnixStream) -> OwnedFd
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
.
impl IntoRawFd for OwnedFd
fn into_raw_fd(self) -> RawFd
impl IsTerminal for OwnedFd
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
impl<T> Any for T
where
T: 'static + ?Sized,
impl<T> Borrow<T> for T
where
T: ?Sized,
impl<T> BorrowMut<T> for T
where
T: ?Sized,
impl<T> From<T> for T
fn from(t: T) -> T
Returns the argument unchanged.
impl<T, U> Into<U> for T
where
U: From<T>,
fn into(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<U> for T
where
U: Into<T>,
type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for T
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/fd/struct.OwnedFd.html