Trait SourceProvider

Source
pub trait SourceProvider: Send + Sync {
    type Error: Error + Send + Sync;

    // Required methods
    fn read<'a>(&'a self, file: &Path) -> Result<&'a str, Self::Error>;
    fn resolve(
        &self,
        specifier: &str,
        originating_file: &Path,
    ) -> Result<PathBuf, Self::Error>;
}
Available on crate feature bundler only.
Expand description

A trait to provide the contents of files to a Bundler.

See FileProvider for an implementation that uses the file system.

Required Associated Types§

Source

type Error: Error + Send + Sync

A custom error.

Required Methods§

Source

fn read<'a>(&'a self, file: &Path) -> Result<&'a str, Self::Error>

Reads the contents of the given file path to a string.

Source

fn resolve( &self, specifier: &str, originating_file: &Path, ) -> Result<PathBuf, Self::Error>

Resolves the given import specifier to a file path given the file which the import originated from.

Implementors§