Expand description
§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");
Structs§
- Default
Resolver - The default resolver. This simply parses path strings using
Path::new()
- Null
Resolver - A resolver that always returns
None
. - Resolver
Chain - An asset resolver that chains sub-resolvers together to attempt to resolve a path using multiple ordered methods.
Traits§
- Asset
Resolver - The asset resolver trait. This should be implemented by any custom resolvers