Expand description
Fetchurl SDK for Rust.
Protocol-level client for fetchurl content-addressable cache servers.
This crate does not perform HTTP requests directly — it provides
a state machine (FetchSession) that drives the protocol logic while
the caller handles I/O with any HTTP library.
§Example
use std::io;
use fetchurl_sdk as fetchurl;
let source_urls = vec!["https://cdn.example.com/file.tar.gz"];
let mut session = fetchurl::FetchSession::new(
"sha256", "e3b0c44...", &source_urls,
).unwrap();
while let Some(attempt) = session.next_attempt() {
// Make HTTP GET to attempt.url() with attempt.headers()
// using your preferred HTTP library.
//
// On success: stream body through session.verifier(writer),
// call verifier.finish(), then session.report_success().
// On failure after bytes written: session.report_partial().
// On failure before any bytes: just continue the loop.
}Structs§
- Fetch
Attempt - A single fetch attempt, describing the URL to request and headers to set.
- Fetch
Session - Drives the fetchurl client protocol as a state machine.
- Hash
Verifier - A writer wrapper that computes a hash of all written data and verifies
it against an expected hash when
finishis called.
Enums§
- Error
- Errors returned by the fetchurl SDK.
Functions§
- encode_
source_ urls - Encode source URLs as an RFC 8941 string list for the
X-Source-Urlsheader. - is_
supported - Check if a hash algorithm is supported.
- normalize_
algo - Normalize a hash algorithm name per the fetchurl spec:
lowercase, keeping only
[a-z0-9]. - parse_
fetchurl_ server - Parse the
FETCHURL_SERVERenvironment variable value (an RFC 8941 string list).