Expand description
Ranged custom-protocol streaming of broker-granted files.
Donors: ViewRight binary_stream.rs (id resolution, HEAD/GET/OPTIONS, single-range parsing,
heavy reads off the calling thread) and stream_http.rs (range parser, fallible response
builders that never panic). The shell registers one or more schemes with
ShellBuilder::stream_protocol("myapp-stream", policy); URLs are myapp-stream://localhost/<id>
(http://myapp-stream.localhost/<id> on Windows). The only credential is the id minted by
crate::broker::PathBroker::grant_stream. Revoking the file revokes its ids for good.
Structs§
- Stream
Event - One observed stream event with the content type of the file it concerns.
- Stream
Observer - A shared callback receiving
StreamEvents. Cheap to clone. A panic inside it is caught and dropped; it never reaches the response. It runs inline on the request path (and on the reader thread forBytesRead), so keep it quick: bump a counter, do not do I/O. - Stream
Policy - Policy for what a stream scheme will serve.
Enums§
- Stream
Event Kind - What happened to one stream request (see
StreamPolicy::observer).
Functions§
- mime_
for - Content type by extension (media and document formats the suite streams).
- parse_
range - Parse one
bytes=a-b/bytes=a-/bytes=-nrange against a known length into an inclusive(start, end). Multi-range requests, empty bodies and unsatisfiable ranges are refused. - serve
- Serve one request. Validation (id, mime, stat, range) is synchronous and cheap; only the body
read runs on a dedicated thread, then
respondis called from there.