Trait jrsonnet_evaluator::ImportResolver
source · pub trait ImportResolver: Trace {
fn load_file_contents(&self, resolved: &SourcePath) -> Result<Vec<u8>>;
fn as_any(&self) -> &dyn Any;
fn resolve_from(&self, from: &SourcePath, path: &str) -> Result<SourcePath> { ... }
fn resolve_from_default(&self, path: &str) -> Result<SourcePath> { ... }
fn resolve(&self, path: &Path) -> Result<SourcePath> { ... }
}
Expand description
Implements file resolution logic for import
and importStr
Required Methods§
sourcefn load_file_contents(&self, resolved: &SourcePath) -> Result<Vec<u8>>
fn load_file_contents(&self, resolved: &SourcePath) -> Result<Vec<u8>>
Load resolved file
This should only be called with value returned from [ImportResolver::resolve_file
]/ImportResolver::resolve
,
this cannot be resolved using associated type, as evaluator uses object instead of generic for ImportResolver
Provided Methods§
sourcefn resolve_from(&self, from: &SourcePath, path: &str) -> Result<SourcePath>
fn resolve_from(&self, from: &SourcePath, path: &str) -> Result<SourcePath>
Resolves file path, e.g. (/home/user/manifests, b.libjsonnet)
can correspond
both to /home/user/manifests/b.libjsonnet
and to /home/user/${vendor}/b.libjsonnet
where ${vendor}
is a library path.
from
should only be returned from ImportResolver::resolve
, or from other defined file, any other value
may result in panic
fn resolve_from_default(&self, path: &str) -> Result<SourcePath>
sourcefn resolve(&self, path: &Path) -> Result<SourcePath>
fn resolve(&self, path: &Path) -> Result<SourcePath>
Resolves absolute path, doesn’t supports jpath and other fancy things