pub fn stream_copy(src: &Path, dst: &Path) -> Result<u64>Expand description
Copies a single file using buffered streaming I/O.
Reads and writes in STREAM_BUFFER_SIZE chunks. Memory usage is
constant regardless of file size — a 1 KB file and a 1 GB file
use the same buffer.
§Examples
use ssg::stream::stream_copy;
use tempfile::tempdir;
use std::fs;
let dir = tempdir().unwrap();
let src = dir.path().join("src.txt");
let dst = dir.path().join("dst.txt");
fs::write(&src, "hello").unwrap();
let bytes = stream_copy(&src, &dst).unwrap();
assert_eq!(bytes, 5);§Errors
Returns an error if the source cannot be read or the destination cannot be written.