Skip to main content

ImportLoader

Trait ImportLoader 

Source
pub trait ImportLoader {
    // Required method
    fn load(&self, path: &str) -> Result<String, String>;

    // Provided method
    fn canonicalize(&self, path: &str) -> String { ... }
}
Expand description

Trait for loading .fd files by path.

Implemented differently by each host environment:

  • WASM: reads from VS Code workspace via message passing
  • LSP: reads from the filesystem
  • CLI/tests: reads from a HashMap or disk

Required Methods§

Source

fn load(&self, path: &str) -> Result<String, String>

Load the contents of a .fd file at the given path.

Provided Methods§

Source

fn canonicalize(&self, path: &str) -> String

Return a canonical form of the path for dedup comparison. Default: returns the path unchanged.

Implementors§