Skip to main content

Module zero_copy

Module zero_copy 

Source
Expand description

Zero-copy data transfer utilities using Linux splice(2).

splice(2) moves data between two file descriptors via a kernel pipe buffer without copying the data through user space. For downloads to regular files this enables the pipeline socket -> pipe -> file, all inside the kernel, eliminating the user-space read/write bounce.

§Platform Support

§Safety

All splice(2) invocations are confined to #[cfg(target_os = "linux")] code paths and operate on valid, open file descriptors owned by the caller. A RAII [PipeGuard] guarantees the intermediate pipe descriptors are closed on every exit path (including early return on error and panics).

Functions§

is_splice_supported
Reports whether splice(2) is available on the current platform.
splice_transfer
Transfer up to len bytes from fd_in to fd_out using splice(2).