Skip to main content

AsFd

Trait AsFd 

1.63.0 · Source
pub trait AsFd {
    // Required method
    fn as_fd(&self) -> BorrowedFd<'_>;
}
Expand description

A trait to borrow the file descriptor from an underlying object.

This is only available on unix platforms and must be imported in order to call the method. Windows platforms have a corresponding AsHandle and AsSocket set of traits.

Required Methods§

1.63.0 · Source

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

Borrows the file descriptor.

§Example
use std::fs::File;

let mut f = File::open("foo.txt")?;
let borrowed_fd: BorrowedFd<'_> = f.as_fd();

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

1.63.0 · Source§

impl AsFd for BorrowedFd<'_>

1.63.0 · Source§

impl AsFd for std::process::ChildStderr

Source§

impl AsFd for compio::process::ChildStderr

1.63.0 · Source§

impl AsFd for std::process::ChildStdin

Source§

impl AsFd for compio::process::ChildStdin

1.63.0 · Source§

impl AsFd for std::process::ChildStdout

Source§

impl AsFd for compio::process::ChildStdout

Source§

impl AsFd for CurrentDir

Source§

impl AsFd for std::fs::Dir

Source§

impl AsFd for compio::fs::Dir

Available on Unix only.
1.63.0 · Source§

impl AsFd for std::fs::File

Available on non-Trusty only.
Source§

impl AsFd for compio::fs::File

Available on Unix only.
1.63.0 · Source§

impl AsFd for OwnedFd

1.87.0 · Source§

impl AsFd for PipeReader

Available on non-Trusty only.
1.87.0 · Source§

impl AsFd for PipeWriter

Available on non-Trusty only.
§

impl AsFd for Poller

§

impl AsFd for Receiver

§

impl AsFd for Receiver

Available on crate feature os-ext only.
Source§

impl AsFd for compio::fs::pipe::Receiver

Available on Unix only.
§

impl AsFd for Registry

Available on Unix and neither AIX nor Cygwin nor ESP-IDF nor Fuchsia nor GNU/Hurd nor Haiku nor Hermit nor Horizon nor NuttX nor Play Station Vita nor QNX SDP 7.x and non-mio_unsupported_force_poll_poll only.
§

impl AsFd for Sender

§

impl AsFd for Sender

Available on crate feature os-ext only.
Source§

impl AsFd for compio::fs::pipe::Sender

Available on Unix only.
§

impl AsFd for Socket

1.63.0 · Source§

impl AsFd for Stderr

1.63.0 · Source§

impl AsFd for Stdin

1.63.0 · Source§

impl AsFd for Stdout

1.63.0 · Source§

impl AsFd for std::net::tcp::TcpListener

Available on non-Trusty only.
§

impl AsFd for TcpListener

§

impl AsFd for TcpListener

Available on Hermit or Unix or WASI only.
Source§

impl AsFd for compio::net::TcpListener

Available on Unix only.
§

impl AsFd for TcpSocket

Available on Unix, or WASI, or docsrs only.
Source§

impl AsFd for compio::net::TcpSocket

Available on Unix only.
1.63.0 · Source§

impl AsFd for std::net::tcp::TcpStream

Available on non-Trusty only.
§

impl AsFd for TcpStream

§

impl AsFd for TcpStream

Available on Hermit or Unix or WASI only.
Source§

impl AsFd for compio::net::TcpStream

Available on Unix only.
1.63.0 · Source§

impl AsFd for std::net::udp::UdpSocket

Available on non-Trusty only.
§

impl AsFd for UdpSocket

§

impl AsFd for UdpSocket

Available on Hermit or Unix or WASI only.
Source§

impl AsFd for compio::net::UdpSocket

Available on Unix only.
1.63.0 · Source§

impl AsFd for std::os::unix::net::datagram::UnixDatagram

§

impl AsFd for UnixDatagram

§

impl AsFd for UnixDatagram

1.63.0 · Source§

impl AsFd for std::os::unix::net::listener::UnixListener

§

impl AsFd for UnixListener

§

impl AsFd for UnixListener

Source§

impl AsFd for compio::net::UnixListener

Available on Unix only.
§

impl AsFd for UnixSocket

Source§

impl AsFd for compio::net::UnixSocket

Available on Unix only.
1.63.0 · Source§

impl AsFd for std::os::unix::net::stream::UnixStream

§

impl AsFd for UnixStream

§

impl AsFd for UnixStream

Source§

impl AsFd for compio::net::UnixStream

Available on Unix only.
1.63.0 · Source§

impl<'a> AsFd for StderrLock<'a>

1.63.0 · Source§

impl<'a> AsFd for StdinLock<'a>

1.63.0 · Source§

impl<'a> AsFd for StdoutLock<'a>

§

impl<'fd> AsFd for PollFd<'fd>

Available on non-Windows only.
Source§

impl<F> AsFd for NamedTempFile<F>
where F: AsFd,

Available on Unix or WASI only.
1.63.0 · Source§

impl<T> AsFd for &T
where T: AsFd + ?Sized,

1.63.0 · Source§

impl<T> AsFd for &mut T
where T: AsFd + ?Sized,

1.64.0 · Source§

impl<T> AsFd for Arc<T>
where T: AsFd + ?Sized,

This impl allows implementing traits that require AsFd on Arc.

use std::net::UdpSocket;
use std::sync::Arc;

trait MyTrait: AsFd {}
impl MyTrait for Arc<UdpSocket> {}
impl MyTrait for Box<UdpSocket> {}
§

impl<T> AsFd for Async<T>
where T: AsFd,

Available on Unix only.
Source§

impl<T> AsFd for compio::runtime::fd::AsyncFd<T>
where T: AsFd,

§

impl<T> AsFd for AsyncFd<T>
where T: AsRawFd,

1.64.0 · Source§

impl<T> AsFd for Box<T>
where T: AsFd + ?Sized,

§

impl<T> AsFd for Filter<T>
where T: AsFd,

Source§

impl<T> AsFd for compio::runtime::fd::PollFd<T>
where T: AsFd,

1.69.0 · Source§

impl<T> AsFd for Rc<T>
where T: AsFd + ?Sized,

Source§

impl<T> AsFd for SharedFd<T>
where T: AsFd,

Source§

impl<T> AsFd for UniqueRc<T>
where T: AsFd + ?Sized,