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 8e9136e
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 @@ -6,6 +6,8 @@ use std::fs::{self, File, OpenOptions};
use std::io::{self, Read, Seek, SeekFrom, Write};
use std::mem;
use std::ops::Deref;
#[cfg(target_os = "wasi")]
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, RawFd};
#[cfg(unix)]
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
#[cfg(windows)]
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 8e9136e

Please sign in to comment.