Use rustix in linux-timerfd example

This commit is contained in:
Taiki Endo 2023-08-30 01:47:25 +09:00
parent 86dad666a1
commit 7e95fff0bf
2 changed files with 2 additions and 3 deletions

View File

@ -49,7 +49,7 @@ url = "2"
[target.'cfg(target_os = "linux")'.dev-dependencies]
inotify = { version = "0.10", default-features = false }
nix = "0.27"
rustix = "0.38"
timerfd = "1"
[target.'cfg(windows)'.dev-dependencies]

View File

@ -8,7 +8,6 @@
#[cfg(target_os = "linux")]
fn main() -> std::io::Result<()> {
use std::os::unix::io::AsRawFd;
use std::time::{Duration, Instant};
use smol::{io, Async};
@ -22,7 +21,7 @@ fn main() -> std::io::Result<()> {
// When the OS timer fires, a 64-bit integer can be read from it.
Async::new(timer)?
.read_with(|t| nix::unistd::read(t.as_raw_fd(), &mut [0u8; 8]).map_err(io::Error::from))
.read_with(|t| rustix::io::read(t, &mut [0u8; 8]).map_err(io::Error::from))
.await?;
Ok(())
}