diff --git a/src/uucore/src/lib/features/pipes.rs b/src/uucore/src/lib/features/pipes.rs index c40dca21c..5ac590b7b 100644 --- a/src/uucore/src/lib/features/pipes.rs +++ b/src/uucore/src/lib/features/pipes.rs @@ -9,7 +9,7 @@ use std::fs::File; #[cfg(any(target_os = "linux", target_os = "android"))] use std::io::IoSlice; #[cfg(any(target_os = "linux", target_os = "android"))] -use std::os::unix::io::AsRawFd; +use std::os::fd::AsFd; #[cfg(any(target_os = "linux", target_os = "android"))] use nix::fcntl::SpliceFFlags; @@ -35,15 +35,8 @@ pub fn pipe() -> Result<(File, File)> { /// a [`pipe`] and then from the pipe into your target (with `splice_exact`): /// this is still very efficient. #[cfg(any(target_os = "linux", target_os = "android"))] -pub fn splice(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> Result { - nix::fcntl::splice( - source.as_raw_fd(), - None, - target.as_raw_fd(), - None, - len, - SpliceFFlags::empty(), - ) +pub fn splice(source: &impl AsFd, target: &impl AsFd, len: usize) -> Result { + nix::fcntl::splice(source, None, target, None, len, SpliceFFlags::empty()) } /// Splice wrapper which fully finishes the write. @@ -52,7 +45,7 @@ pub fn splice(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> Resul /// /// Panics if `source` runs out of data before `len` bytes have been moved. #[cfg(any(target_os = "linux", target_os = "android"))] -pub fn splice_exact(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> Result<()> { +pub fn splice_exact(source: &impl AsFd, target: &impl AsFd, len: usize) -> Result<()> { let mut left = len; while left != 0 { let written = splice(source, target, left)?; @@ -66,10 +59,6 @@ pub fn splice_exact(source: &impl AsRawFd, target: &impl AsRawFd, len: usize) -> /// /// Returns the number of successfully copied bytes. #[cfg(any(target_os = "linux", target_os = "android"))] -pub fn vmsplice(target: &impl AsRawFd, bytes: &[u8]) -> Result { - nix::fcntl::vmsplice( - target.as_raw_fd(), - &[IoSlice::new(bytes)], - SpliceFFlags::empty(), - ) +pub fn vmsplice(target: &impl AsFd, bytes: &[u8]) -> Result { + nix::fcntl::vmsplice(target, &[IoSlice::new(bytes)], SpliceFFlags::empty()) }