pub trait AsFd {
// Required method
fn as_fd(&self) -> BorrowedFd<'_>;
}
Available on crate feature
dep_rustix
only.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 · Sourcefn as_fd(&self) -> BorrowedFd<'_>
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();
Implementors§
impl AsFd for File
impl AsFd for devela::_dep::_std::io::Stderr
impl AsFd for devela::_dep::_std::io::Stdin
impl AsFd for devela::_dep::_std::io::Stdout
impl AsFd for devela::_dep::_std::net::TcpListener
impl AsFd for devela::_dep::_std::net::TcpStream
impl AsFd for devela::_dep::_std::net::UdpSocket
impl AsFd for PidFd
impl AsFd for devela::_dep::_std::os::unix::net::UnixDatagram
impl AsFd for devela::_dep::_std::os::unix::net::UnixListener
impl AsFd for devela::_dep::_std::os::unix::net::UnixStream
impl AsFd for PipeReader
impl AsFd for PipeWriter
impl AsFd for ChildStderr
impl AsFd for ChildStdin
impl AsFd for ChildStdout
impl AsFd for devela::_dep::tokio::io::Stderr
impl AsFd for devela::_dep::tokio::io::Stdin
impl AsFd for devela::_dep::tokio::io::Stdout
impl AsFd for BorrowedFd<'_>
impl AsFd for OwnedFd
impl AsFd for Receiver
impl AsFd for Sender
impl AsFd for TcpListener
impl AsFd for TcpStream
impl AsFd for UdpSocket
impl AsFd for UnixDatagram
impl AsFd for UnixListener
impl AsFd for UnixStream
impl<'a> AsFd for StderrLock<'a>
impl<'a> AsFd for StdinLock<'a>
impl<'a> AsFd for StdoutLock<'a>
impl<'fd> AsFd for PollFd<'fd>
impl<T> AsFd for &T
impl<T> AsFd for &mut T
impl<T> AsFd for Box<T>
impl<T> AsFd for Rc<T>
impl<T> AsFd for Arc<T>
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> {}