2 releases
0.1.1 | Jan 6, 2022 |
---|---|
0.1.0 | Jan 6, 2022 |
#956 in Filesystem
17KB
106 lines
Asset Resolver
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:
DefaultResolver
- Turns strings into literal paths
NullResolver
- Always fails
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");