Skip to main content

FileResolver

Trait FileResolver 

Source
pub trait FileResolver {
    // Required method
    fn resolve(&self, path: &str, relative_to: &str) -> Result<String, Error>;

    // Provided method
    fn resolve_path(
        &self,
        path: &str,
        _relative_to: &str,
    ) -> Result<String, Error> { ... }
}
Expand description

Trait for resolving .include file paths to their contents. Abstracted as a trait so tests can use an in-memory mock.

Required Methods§

Source

fn resolve(&self, path: &str, relative_to: &str) -> Result<String, Error>

Resolve an include path relative to the including file’s directory. Returns the file contents.

Provided Methods§

Source

fn resolve_path(&self, path: &str, _relative_to: &str) -> Result<String, Error>

Resolve the filename used for nested includes and cycle detection. The returned name must also be accepted by resolve. Resolvers with a flat virtual namespace may keep the default behavior.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§