Skip to main content

RangeFetcher

Trait RangeFetcher 

Source
pub trait RangeFetcher {
    // Required methods
    fn fetch(
        &mut self,
        start: u64,
        end_inclusive: u64,
    ) -> Result<Vec<u8>, FetchError>;
    fn total_size(&self) -> u64;

    // Provided method
    fn extra_requests(&self) -> u32 { ... }
}
Expand description

A transport that serves byte ranges of one remote file.

Implemented by HttpRangeFetcher for production and by in-memory fetchers in tests. The contract: fetch(start, end_inclusive) returns exactly end_inclusive - start + 1 bytes of the file’s content at start, and total_size is the file’s full length in bytes, known up front.

Required Methods§

Source

fn fetch( &mut self, start: u64, end_inclusive: u64, ) -> Result<Vec<u8>, FetchError>

Fetches the inclusive byte range start..=end_inclusive.

§Errors

Returns FetchError::Http when the transport fails (network error, unexpected HTTP status, validation mismatch).

Source

fn total_size(&self) -> u64

Total size of the remote file in bytes.

Provided Methods§

Source

fn extra_requests(&self) -> u32

Requests spent by the transport outside RangeFetcher::fetch (e.g. the eager probe that resolved the file size and classified access). Included in RangeReader::stats so the reported request count is honest.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§