Trait std::os::wasi::io::AsFd

pub trait AsFd {
    fn as_fd(&self) -> BorrowedFd<'_>;
}
???? This is a nightly-only experimental API. (io_safety #87074)
This is supported on WASI only.

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

???? 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();

Implementors

© 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/wasi/io/trait.AsFd.html