Skip to main content

Crate fetchurl_sdk

Crate fetchurl_sdk 

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

FetchAttempt
A single fetch attempt, describing the URL to request and headers to set.
FetchSession
Drives the fetchurl client protocol as a state machine.
HashVerifier
A writer wrapper that computes a hash of all written data and verifies it against an expected hash when finish is 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-Urls header.
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_SERVER environment variable value (an RFC 8941 string list).