Skip to content

Commit

Permalink
Make AsFd/AsRawFd implementations available on wasi
Browse files Browse the repository at this point in the history
`std` provides these traits on wasi, so we should probably do so as well.
  • Loading branch information
LingMan committed Jul 5, 2023
1 parent 391c530 commit 682f52a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::mem;
use std::ops::Deref;
#[cfg(unix)]
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
#[cfg(target_os = "wasi")]
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd};
#[cfg(windows)]
use std::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle, RawHandle};
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -1038,14 +1040,14 @@ impl Seek for &NamedTempFile<File> {
}
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "wasi"))]
impl<F: AsFd> AsFd for NamedTempFile<F> {
fn as_fd(&self) -> BorrowedFd<'_> {
self.as_file().as_fd()
}
}

#[cfg(unix)]
#[cfg(any(unix, target_os = "wasi"))]
impl<F: AsRawFd> AsRawFd for NamedTempFile<F> {
#[inline]
fn as_raw_fd(&self) -> RawFd {
Expand Down

0 comments on commit 682f52a

Please sign in to comment.