Skip to main content

FileSource

Trait FileSource 

Source
pub trait FileSource: Send + Sync {
    // Required method
    fn open(&self) -> Result<SourceReader>;
}
Expand description

A provider of virtual file contents.

Each call to FileSource::open must create a fresh, independent reader positioned at the beginning of the file.

A receiving application may request the contents of the same virtual file multiple times or concurrently.

Implementations must be safe to share across threads.

Required Methods§

Source

fn open(&self) -> Result<SourceReader>

Opens a new reader for this file’s contents.

The returned reader must not depend on the position of readers returned by earlier calls.

§Errors

Returns an I/O error if the contents cannot be opened or prepared.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<F> FileSource for FactorySource<F>
where F: Fn() -> Result<SourceReader> + Send + Sync,