Expand description
Asset resolution framework.
USD layers reference external assets through asset paths — the @...@ syntax in
.usda files. These paths appear in sublayers, references, payloads, and asset-valued
attributes. An asset path is a logical identifier that may be relative, absolute, or
use package-relative notation (Model.usdz[Geom.usd]).
This module resolves those logical paths to physical locations that can be opened and read. It corresponds to the C++ Ar (Asset Resolution) module: https://openusd.org/dev/api/ar_page_front.html
The Resolver trait defines the resolution interface. The DefaultResolver
provides a filesystem-based implementation that searches configurable directories
for matching files. Custom resolvers can map asset paths to databases, cloud storage,
or other backends.
§Example
use openusd::ar::{DefaultResolver, Resolver};
let resolver = DefaultResolver::new();
if let Some(resolved) = resolver.resolve("model.usda") {
let mut asset = resolver.open_asset(&resolved).unwrap();
let data = asset.read_all().unwrap();
}Structs§
- Asset
Info - Metadata about a resolved asset.
- Cache
Handle - A cache scope’s cache, by reference: clones share the one cache, and the cache is released when the last of them drops.
- Cache
Scope - A cache scope (C++
ArResolverScopedCache): a span, on one thread, over which work that asks for the same asset several times keeps what it opened, such as a package’s directory. The scope ends when the guard drops. - Default
Resolver - Default filesystem-based asset resolver.
- Resolved
Path - A resolved asset path representing the physical location of an asset.
- Shared
Buffer - A view of bytes a
SharedSourceholds: the range of the source it covers, which it never outgrows. A clone shares the source, andslicenarrows the range without copying. A package entry is therefore a view of its package, and a layer’s bytes a view of its asset.
Enums§
- Advice
- How a range of shared bytes is about to be read, for a source that can
prepare for it (C++
ArchMemAdvice). - Asset
Buffer - The bytes a layer decodes from: an asset’s complete contents, as
Asset::into_bufferyields them, or bytes that never were an asset, compiled into the program or handed over by a host. They live as long as the layer because a decoder may keep reading them: the crate format indexes into the buffer in place, while the text format copies out what it keeps.
Traits§
- Asset
- Readable asset handle returned by
Resolver::open_asset. - Resolver
- Interface for resolving asset paths to physical locations.
- Shared
Source - The backing a
SharedBufferviews: bytes whose length and contents are fixed for as long as the source lives. The trait is sealed since every view relies on that promise; the sources are&'static [u8],Vec<u8>,Arc<[u8]>and, with themmapfeature, a read-only file mapping, whose promise is the oneDefaultResolver::map_fileshas its caller make.
Functions§
- is_
package_ relative_ path - Returns
trueif the path contains a package-relative component (bracket syntax). - join_
package_ relative_ path - Joins a package path and an inner path into a package-relative path.
- split_
package_ relative_ path_ inner - Splits a package-relative path at the innermost bracket.
- split_
package_ relative_ path_ outer - Splits a package-relative path at the outermost bracket.