pub trait ScriptContentProvider<T> {
// Required methods
fn load(&mut self, path: &str) -> Result<Option<T>, Box<dyn Error>>;
fn join_paths(
&self,
parent: &str,
relative: &str,
) -> Result<String, Box<dyn Error>>;
// Provided methods
fn unpack_load(
&mut self,
path: &str,
) -> Result<Vec<ScriptContent<T>>, Box<dyn Error>> { ... }
fn sanitize_path(&self, path: &str) -> Result<String, Box<dyn Error>> { ... }
}Expand description
Fetches script source by path.
A frontend follows imports through this trait. Where the source lives, on disk, in an archive or generated on the fly, is then not the frontend’s problem.
Required Methods§
Provided Methods§
Sourcefn unpack_load(
&mut self,
path: &str,
) -> Result<Vec<ScriptContent<T>>, Box<dyn Error>>
fn unpack_load( &mut self, path: &str, ) -> Result<Vec<ScriptContent<T>>, Box<dyn Error>>
Loads a path that may hold several units, such as an archive.
Defaults to a single ScriptContentProvider::load.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".