Idea: Add an option to set the mode to fs::copy
Rust Internals [Unofficial]
March 14, 2026
chrisd:
On Windows ... there's no single function to copy using file handles ... there are some low-level functions which can help, such as
NtCopyFileChunk, but [it doesn't do the whole job and] doesn't work in all cases ...
Linux's copy_file_range also doesn't do the whole job and doesn't work in all cases; callers need to check for a "can't do it this time" error return and fall back to a manual copy loop. It sounds like the Windows implementation of io::copy might usefully be taught to use NtCopyFileChunk if it doesn't already, but fs::copy on Windows should keep using CopyFile, would you agree?
Discussion in the ATmosphere