Skip to main content

HttpRangeReader

Type Alias HttpRangeReader 

Source
pub type HttpRangeReader = RangeReader<HttpRangeFetcher>;
Expand description

RangeReader over HttpRangeFetcher — the production remote-inspect substrate.

Aliased Type§

pub struct HttpRangeReader { /* private fields */ }

Implementations§

Source§

impl HttpRangeReader

Source

pub async fn open( repo_id: &str, revision: Option<&str>, filename: &str, token: Option<&str>, ) -> Result<Self, FetchError>

Opens a range reader over filename in repo_id at revision (default main).

Performs the probe eagerly, so failures (missing file, gated repo, no Range support) surface here as typed errors rather than mid-parse io::Errors.

Must be called from within a tokio runtime; the returned reader is then handed to a blocking context (tokio::task::spawn_blocking), where its Read / Seek impls drive async requests via the captured runtime handle.

§Errors

Returns FetchError::Http if the probe fails, the repository or file is inaccessible (including gated repos: returned status 401/403 errors, which the CLI upgrades into a gated-repo diagnosis), or the server does not support Range requests.

Source

pub async fn open_with_limits( repo_id: &str, revision: Option<&str>, filename: &str, token: Option<&str>, max_requests: u32, max_transfer_bytes: u64, ) -> Result<Self, FetchError>

Opens a range reader with explicit safety budgets (see RangeReader::with_limits) instead of the MAX_RANGE_REQUESTS / MAX_TRANSFER_BUDGET defaults HttpRangeReader::open uses.

The defaults are tuned for archive-header parsing (inspect’s .safetensors / .gguf / .npz / .pth paths) — a handful of requests, well under 1 MiB. A caller with its own, larger, user-facing byte budget (hf-fm peek’s --max) needs its transport budget sized to match, or safety limits tuned for header parsing cut it off first with a misleading “pathological archive layout” error.

Same preconditions as HttpRangeReader::open (must be called from within a tokio runtime; the reader is then driven from a blocking context).

§Errors

Same as HttpRangeReader::open.

Source

pub fn probe_etag(&self) -> &str

The etag observed at probe time, before any range request.

Lets a caller key a cache entry (inspect --cache-headers) on the same etag hf-hub’s own blob layout uses, without an extra round trip beyond the probe HttpRangeReader::open already made.