11 releases (7 breaking)
0.9.1 | Nov 12, 2024 |
---|---|
0.8.0 | May 7, 2024 |
0.7.0 | Feb 23, 2024 |
0.3.0 | Oct 26, 2023 |
#270 in Network programming
10,784 downloads per month
Used in 4 crates
(2 directly)
47KB
841 lines
Async HTTP Range Reader
A crate that provides the AsyncHttpRangeReader
struct, which allows streaming files over HTTP using range requests.
lib.rs
:
This library provides the AsyncHttpRangeReader
type.
It allows streaming a file over HTTP while also allow random access. The type implements both
AsyncRead
as well as AsyncSeek
. This is supported through the use of range requests.
Each individual read will request a portion of the file using an HTTP range request.
Requesting numerous small reads might turn out to be relatively slow because each reads needs to
perform an HTTP request. To alleviate this issue AsyncHttpRangeReader::prefetch
is provided.
Using this method you can prefect a number of bytes which will be streamed in on the
background. If a read operation is reading from already (pre)fetched ranges it will stream from
the internal cache instead.
Internally the AsyncHttpRangeReader
stores a memory map which allows sparsely reading the
data into memory without actually requiring all memory for file to be resident in memory.
The primary use-case for this library is to be able to sparsely stream a zip archive over HTTP but its designed in a generic fashion.
Dependencies
~8–19MB
~243K SLoC