pub trait Loader {
// Required method
fn load(
&self,
specifier: &ModuleSpecifier,
options: LoadOptions,
) -> LoadFuture;
// Provided methods
fn max_redirects(&self) -> usize { ... }
fn cache_info_enabled(&self) -> bool { ... }
fn get_cache_info(&self, _specifier: &ModuleSpecifier) -> Option<CacheInfo> { ... }
fn ensure_cached(
&self,
specifier: &ModuleSpecifier,
options: LoadOptions,
) -> EnsureCachedFuture { ... }
}
Expand description
A trait which allows asynchronous loading of source files into a module graph in a thread safe way as well as a way to provide additional meta data about any cached resources.
Required Methods§
Sourcefn load(&self, specifier: &ModuleSpecifier, options: LoadOptions) -> LoadFuture
fn load(&self, specifier: &ModuleSpecifier, options: LoadOptions) -> LoadFuture
A method that given a specifier that asynchronously returns the source of the file.
To ensure errors surfaced in the graph are more specific for checksum
integrity errors, ensure this returns a ChecksumIntegrityError
when
the checksum on LoadOptions
does not match the loaded source.
Provided Methods§
Sourcefn max_redirects(&self) -> usize
fn max_redirects(&self) -> usize
The maximum number of redirects allowed.
Sourcefn cache_info_enabled(&self) -> bool
fn cache_info_enabled(&self) -> bool
Whether getting cache info is enabled.
Sourcefn get_cache_info(&self, _specifier: &ModuleSpecifier) -> Option<CacheInfo>
fn get_cache_info(&self, _specifier: &ModuleSpecifier) -> Option<CacheInfo>
An optional method which returns cache info for a module specifier.
Sourcefn ensure_cached(
&self,
specifier: &ModuleSpecifier,
options: LoadOptions,
) -> EnsureCachedFuture
fn ensure_cached( &self, specifier: &ModuleSpecifier, options: LoadOptions, ) -> EnsureCachedFuture
Ensures the specified module is cached.
By default, this will just call load
, but you can override
this to provide a more optimal way of caching that doesn’t
load the bytes into memory.