Skip to main content

Module stream

Module stream 

Source
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§

StreamEvent
One observed stream event with the content type of the file it concerns.
StreamObserver
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 for BytesRead), so keep it quick: bump a counter, do not do I/O.
StreamPolicy
Policy for what a stream scheme will serve.

Enums§

StreamEventKind
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=-n range 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 respond is called from there.