Skip to main content

DataSource

Trait DataSource 

Source
pub trait DataSource: Send + Sync {
    // Required methods
    fn size(&self) -> Result<u64>;
    fn read_range(&self, range: ByteRange) -> Result<Vec<u8>>;

    // Provided methods
    fn read_ranges(&self, ranges: &[ByteRange]) -> Result<Vec<Vec<u8>>> { ... }
    fn supports_range_requests(&self) -> bool { ... }
}
Expand description

Trait for synchronous data sources

Required Methods§

Source

fn size(&self) -> Result<u64>

Returns the total size of the data source in bytes

Source

fn read_range(&self, range: ByteRange) -> Result<Vec<u8>>

Reads bytes from the specified range

Provided Methods§

Source

fn read_ranges(&self, ranges: &[ByteRange]) -> Result<Vec<Vec<u8>>>

Reads bytes from multiple ranges (for optimization)

Source

fn supports_range_requests(&self) -> bool

Returns true if this data source supports range requests

Implementors§