# Trait std::os::unix::io::AsFd
[−][src]

    pub trait AsFd {
        fn as_fd(&self) -> BorrowedFd<'_>;
    }

🔬 This is a nightly-only experimental API. (`io_safety` #87074)
This is supported on Unix 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

[src]

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

🔬 This is a nightly-only experimental API. (`io_safety` #87074)

Borrows the file descriptor.

##### Example

    use std::fs::File;

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

Run

## Implementors

[src]

### impl AsFd for File

[src]

### impl AsFd for Stderr

[src]

### impl AsFd for Stdin

[src]

### impl AsFd for Stdout

[src]

### impl AsFd for TcpListener

[src]

### impl AsFd for TcpStream

[src]

### impl AsFd for UdpSocket

[src]

### impl AsFd for ChildStderr

[src]

### impl AsFd for ChildStdin

[src]

### impl AsFd for ChildStdout

[src]

### impl AsFd for PidFd

This is supported on Linux only.
[src]

### impl AsFd for UnixDatagram

[src]

### impl AsFd for UnixListener

[src]

### impl AsFd for UnixStream

[src]

### impl AsFd for BorrowedFd<'_>

[src]

### impl AsFd for OwnedFd

[src]

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

[src]

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

[src]

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