External Publication
Visit Post

Idea: Add an option to set the mode to fs::copy

Rust Internals [Unofficial] March 18, 2026
Source

splice only works if at least one of the specified file descriptors refers to a pipe – it won't be able to copy between two regular files on unrelated filesystems.

It would be possible to implement a copy by splicing from one file to the other via a pipe (which may require several system calls because a pipe has a limited capacity). I don't know how this compares performance-wise with a manual copy (although I'd expect it to be a bit faster).

Another option is sendfile, which (in recent kernels) has the restriction that the file being copied from is mmap-able (or that the call can be desugared into splice). This would be able to handle almost all combinations of files, but not quite all of them (e.g. if both the input and output are sockets, none of sendfile, splice or copy_file_range would work).

Discussion in the ATmosphere

Loading comments...