pub fn sendfile(
    in_fd: RawFd,
    out_sock: RawFd,
    offset: off_t,
    count: Option<usize>,
    headers: Option<&[&[u8]]>,
    trailers: Option<&[&[u8]]>,
    flags: SfFlags,
    readahead: u16
) -> (Result<()>, off_t)
Expand description

Read up to count bytes from in_fd starting at offset and write to out_sock.

Returns a Result and a count of bytes written. Bytes written may be non-zero even if an error occurs.

in_fd must describe a regular file or shared memory object. out_sock must describe a stream socket.

If offset falls past the end of the file, the function returns success and zero bytes written.

If count is None or 0, bytes will be read from in_fd until reaching the end of file (EOF).

headers and trailers specify optional slices of byte slices to be sent before and after the data read from in_fd, respectively. The length of headers and trailers sent is included in the returned count of bytes written. The values of offset and count do not apply to headers or trailers.

readahead specifies the minimum number of pages to cache in memory ahead of the page currently being sent.

For more information, see the sendfile(2) man page.