Expand description
Efficient partial file transfer over HTTP, compatible with zsync.
A .zsync control file describes a target file as a list of block
checksums. A client that already holds similar data, such as an older
version of the same file, finds the blocks it has locally and downloads
only the rest with HTTP range requests. Nothing beyond a plain web server
that honours Range is needed on the serving side.
ZsyncAssembly drives a whole transfer and is the place to start. The
modules beneath it are public for callers that need one piece on its own:
control reads and writes control files, matcher finds known
blocks in local data, http fetches ranges, and checksum and
rsum are the hashes the format is built on.
use std::path::Path;
use zsync_rs::ZsyncAssembly;
let mut assembly =
ZsyncAssembly::from_url("https://example.com/file.zsync", Path::new("file.bin"))?;
assembly.submit_source_file(Path::new("old-file.bin"))?;
while assembly.download_missing_blocks()? > 0 {}
// Fails if any block is still missing, then verifies the SHA-1.
assembly.complete()?;Re-exports§
pub use assembly::AssemblyError;pub use assembly::ZsyncAssembly;pub use control::ControlFile;pub use control::GenerateError;pub use control::WriteError;pub use http::HttpClient;pub use http::HttpError;pub use matcher::BlockMatcher;
Modules§
- assembly
- Assembling a target file from local sources and HTTP ranges.
- checksum
- The strong hashes zsync relies on.
- control
- The
.zsynccontrol file: parsing, generation and writing. - http
- HTTP transport: control files, byte ranges, and planning range requests.
- matcher
- Finding target blocks in local data, and tracking which are known.
- rsum
- The rolling checksum that lets a scan test every byte offset cheaply.