pub trait Loader {
// Required method
fn load(&self, name: &str) -> Result<Vec<(String, String)>, String>;
// Provided methods
fn entry_package(&self, _path: &Path) -> Option<String> { ... }
fn needs(
&self,
_package: &str,
_entry_dir: Option<&Path>,
) -> Option<BTreeSet<String>> { ... }
fn version(
&self,
_package: &str,
_entry_dir: Option<&Path>,
) -> Option<String> { ... }
}Expand description
Supplies the source of a named bidama.
One method, because resolution needs exactly one thing: given a name, the blue source that name refers to. Where it came from — a working tree, a nix store path, a git object, memory — is the implementation’s business and deliberately invisible here.
Required Methods§
Sourcefn load(&self, name: &str) -> Result<Vec<(String, String)>, String>
fn load(&self, name: &str) -> Result<Vec<(String, String)>, String>
The .b sources of name, as (label, source) pairs.
The label is for diagnostics only; nothing keys on it. A package with
several files returns several pairs, and their relative order is the
implementation’s to fix — FsLoader
sorts by filename so a load is reproducible rather than
directory-order-dependent.
Err is a human-readable reason the package could not be loaded. It
must name what was looked for, because “package not found” without a
name sends the reader grepping a distribution to find which one.
Provided Methods§
Sourcefn entry_package(&self, _path: &Path) -> Option<String>
fn entry_package(&self, _path: &Path) -> Option<String>
The bidama an ENTRY file at path belongs to, if it belongs to one:
the package(name, …) of the Bluefile beside it. blue test bidamas/retsu/retsu.b checks and runs retsu’s own definitions, under
retsu’s namespace, exactly as an importer sees them.
A file with no bidama around it (a script, spec/*.b) is in the root
namespace, and so is every entry a loader without a filesystem is
handed, which is this default.
Sourcefn needs(
&self,
_package: &str,
_entry_dir: Option<&Path>,
) -> Option<BTreeSet<String>>
fn needs( &self, _package: &str, _entry_dir: Option<&Path>, ) -> Option<BTreeSet<String>>
The bidamas package’s Bluefile needs, when the loader can read it.
None when it cannot, and the check stage then has nothing to compare
the package’s use forms against (B0019).
entry_dir is the directory of the entry file, for the entry’s own
bidama, which a loader may not find under its roots.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".