Skip to main content

FileContentSource

Trait FileContentSource 

Source
pub trait FileContentSource {
    // Required method
    fn read_prefix(
        &self,
        path: &str,
        max_bytes: u64,
    ) -> Result<FileContent, ContentError>;
}
Expand description

Where the association pass gets file bytes.

A trait so the association logic is pure and testable without a filesystem, so a future source backend that can re-materialize its own content (an archive member, a container layer) can supply it without this module learning about that backend, and so a caller that owns a retry policy can wrap the implementation instead of this module growing a loop.

Required Methods§

Source

fn read_prefix( &self, path: &str, max_bytes: u64, ) -> Result<FileContent, ContentError>

Read at most max_bytes from path, or say why not.

§Errors

Returns ContentError when the file cannot be opened, cannot be read, or its prefix is not valid UTF-8.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§