Skip to main content

ImageSource

Trait ImageSource 

Source
pub trait ImageSource: Send + Sync {
    // Required methods
    fn len(&self) -> u64;
    fn read_at(&self, offset: u64, buf: &mut [u8]) -> VfsResult<usize>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn extents(&self) -> Extents { ... }
    fn view(&self, offset: u64, len: usize) -> Option<SourceView<'_>> { ... }
    fn source_id(&self) -> SourceId { ... }
}
Expand description

A read-only, randomly-addressable byte stream: a decoded container, a partition window, a decrypted volume, a VSS store, a file’s data, or a byte range of any of them. Send + Sync; positioned reads only; no writer.

Required Methods§

Source

fn len(&self) -> u64

Logical size in bytes of this stream.

Source

fn read_at(&self, offset: u64, buf: &mut [u8]) -> VfsResult<usize>

Fill buf starting at byte offset. Returns bytes read (0 at/after EOF). Never panics; a short read past EOF returns the available prefix length.

Provided Methods§

Source

fn is_empty(&self) -> bool

True when the stream is zero-length.

Source

fn extents(&self) -> Extents

Allocated-extent map. Default = one dense extent covering [0, len).

Source

fn view(&self, offset: u64, len: usize) -> Option<SourceView<'_>>

Optional zero-copy fast path. None when the backing cannot lend a contiguous view (the caller then uses ImageSource::read_at).

Source

fn source_id(&self) -> SourceId

Stable identity for cache keying and lineage.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§