#resolver #path #assets #translation

asset-resolver

A standard system for asset path resolution

2 releases

0.1.1 Jan 6, 2022
0.1.0 Jan 6, 2022

#996 in Filesystem

GPL-3.0 license

17KB
106 lines

Asset Resolver

Crates.io Docs.rs Build Clippy Audit

The Asset Resolver crate exists to allow programs to create resolvers that can convert arbitrary path strings into filesystem paths.

The goal of this crate is to provide a simple and extensible API for other crates to use to provide their own resolvers. Crates should then be able to chain together lists of various other resolvers to efficiently convert identifiers into usable absolute paths.

Example resolvers would be as follows:

  • URI to local filesystem
  • Windows to UNIX
  • Network path to mountpoint
  • Anything else

This crate provides the following resolvers:

Example Usage

use asset_resolver::*;
let resolver = ResolverChain::new(vec![
    Box::new(NullResolver),
    Box::new(DefaultResolver),
]);

let path = resolver.resolve("/home/user/assets/test.png").unwrap();
assert_eq!(path.to_str().unwrap(), "/home/user/assets/test.png");

No runtime deps