@@ -5,11 +5,15 @@ use std::ffi::OsString;
55use std:: os:: raw;
66use std:: os:: unix:: ffi:: OsStringExt ;
77use std:: os:: unix:: io:: RawFd ;
8+ // For splice and copy_file_range
9+ #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" ) ) ]
10+ use std:: {
11+ os:: unix:: io:: { AsRawFd , AsFd } ,
12+ ptr
13+ } ;
814
915#[ cfg( feature = "fs" ) ]
1016use crate :: { sys:: stat:: Mode , NixPath , Result } ;
11- #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" ) ) ]
12- use std:: ptr; // For splice and copy_file_range
1317
1418#[ cfg( any(
1519 target_os = "linux" ,
@@ -593,10 +597,10 @@ type type_of_off = libc::off_t;
593597/// On successful completion the number of bytes actually copied will be
594598/// returned.
595599 #[ cfg( any( target_os = "android" , target_os = "freebsd" , target_os = "linux" ) ) ]
596- pub fn copy_file_range(
597- fd_in: RawFd ,
600+ pub fn copy_file_range< Fd1 : AsFd , Fd2 : AsFd > (
601+ fd_in: Fd1 ,
598602 off_in: Option <& mut type_of_off>,
599- fd_out: RawFd ,
603+ fd_out: Fd2 ,
600604 off_out: Option <& mut type_of_off>,
601605 len: usize ,
602606) -> Result <usize > {
@@ -609,9 +613,9 @@ pub fn copy_file_range(
609613
610614 let ret = unsafe {
611615 libc:: copy_file_range(
612- fd_in,
616+ fd_in. as_fd ( ) . as_raw_fd ( ) ,
613617 off_in,
614- fd_out,
618+ fd_out. as_fd ( ) . as_raw_fd ( ) ,
615619 off_out,
616620 len,
617621 0 ,
0 commit comments