[][src]Trait weldr::FileRefResolver

pub trait FileRefResolver {
    fn resolve(&self, filename: &str) -> Vec<u8>;
}

Resolver trait for sub-file references (Line Type 1 LDraw command).

An implementation of this trait must be passed to parse() to allow resolving sub-file references recursively, and parsing all dependent sub-files of the top-level file being parsed. Implementations are free to decide how to retrieve the file, but must ensure that all canonical paths are in scope, as sub-file references can be relative to any of those:

  • /p/ - Parts primitives
  • /p/48/ - High-resolution primitives
  • /parts/ - Main catalog of parts
  • /parts/s/ - Catalog of sub-parts commonly used

Required methods

fn resolve(&self, filename: &str) -> Vec<u8>

Resolve the given file reference filename, given as it appears in a sub-file reference, and return the content of the file as a UTF-8 encoded buffer of bytes, without BOM. Line ending can be indifferently Unix style \n or Windows style \r\n.

See parse() for usage.

Loading content...

Implementors

Loading content...