Bytes, a mapping, http::File, and the kept mappings (ADR-058)Open and answer this issue on GitHub.
libraries, ready · opened 2026-09-30 · updated 2026-10-08 · 1 comment
ADR-058 (see also PR #45): D1’s Bytes body row, D2’s http::File for a file the program never read, D3’s mechanism choice std makes between them, D8’s kept mappings that measured fastest. Nothing built. What is built is the bench that decided it (benches/sendfile/) and the write-up (docs/history/zero-copy-send.md); send_file beside the ring was deliberately not built ahead of the server, because D3’s measurement makes it the mechanism that loses at the sizes a server sends most. http::File(path, root) inherits fs::Root (ADR-108, built at 0.0.178).
Built in 0.0.681 (96da980), against ADR-289 D22–D30, which superseded ADR-058:
Response.body in the http package is now a Body: Text(String), Bytes(Bytes) or File(http::File). Response::bytes(b) is 200 application/octet-stream.http::File(path, root) looks at the file when it is made. Its size becomes content-length, and its type follows the extension (html, txt, css, js, json, svg, png, jpg; anything else is bytes). A missing file is a 500 and a name that leaves its root is a 404, both settled before the status line. The bytes are read only when the answer is sent, with fs::read through the reactor, so a cold file does not block the server (D30). A read that fails after the head closes the connection short and is logged.hello-http serves /source, /missing and /outside. tests/project.rs checks all three: the bytes match the file, then 500 and 404.File was taken for fs::File and its constructor demanded throws. A type the program declares, or one it names qualified, is now itself.Not built:
sendfile(2) and a mapping written out need a system call std does not make yet, and that call belongs in an unsafe crate (ADR-218). The plain read is one of D24’s three mechanisms, so the answers are right today; what is missing is the zero-copy path.send-file key, which only matters once there is a choice to overrule.static-cache key. Nothing is kept today, which D29 allows (“no hit is promised”).String or Bytes returned directly). listen takes fn(Request) -> Response, and returning any of several types needs a way to write “one of these” that the package does not have yet.Generated by Claude Code