zio-sendfile

Rust crate to provide a higher level abstraction over Linux's zero-copy I/O syscall: sendfile. This provides a significantly faster variant of io::copy(&mut source, &mut dest), which only works on Linux -- the platform of choice for the discerning programmer.

Examples

If you're simply copying a file to a different file descriptor, the copy function can be used:

```rust extern crate zio_sendfile;

let mut source = File::open("sourcepath").unwrap(); let mut dest = File::create("destpath").unwrap(); let bytesperwrite = 100 * 1024 * 1024;

ziosendfile::copy(&mut source, &mut dest, bytesper_write); ```

Note that the source and destination does not need to be a File, but can be any type which implements AsRawFd.

If you need a more elaborate configuration, the builder pattern is possible using the SendFile type:

```rust extern crate zio_sendfile;

let mut source = File::open("sourcepath").unwrap(); SendFile::new(&mut source, 100 * 1024 * 1024) .offset(bytestooffset) .send(&mut File::create("destpath").unwrap()).unwrap(); ```

Each write will update the offset integer stored within the SendFile, so it can be used to track the progress of a copy.