Skip to main content

install_zerocopy

Function install_zerocopy 

Source
pub unsafe fn install_zerocopy(
    response: &mut Response<impl Body>,
    handle: RawFd,
)
Expand description

Installs a zero-copy hint on an HTTP response, directing the connection handler to use emulated sendfile (Linux only) to transmit the body.

§Parameters

  • response – the response whose extensions will receive the hint.
  • handle – the raw file descriptor of the file to send. The caller is responsible for ensuring the file descriptor remains valid and open for the entire duration of the response write.

§Safety

The caller must guarantee that handle is a valid, open file descriptor that will not be closed before the response body has been fully sent.