Proper dependency management for asset loading
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
### Problem
I have a scene definition language (`cuicui_chirp`) that may depend on the content of other files.
I call "dependent" the file that depends on another one, while "dependency" is the file a dependent file depends on.
I need the actual content of the dependency file in order to interpret dependent files.
The current `LoadContext` interface let me access the content of a different asset through the `LoadContext::load_direct` API. However, in my situation, I will have many dependent that depend on a single dependency. `load_direct` does not cache/re-use loaded assets. Which is problematic, I want to load and parse each file once, then re-use the AST.
Shaders has a similar issue. The implementation of loading and re-using shader dependency in bevy is very complex, and could benefit from re-using a holistic `bevy_asset` solution.
### Potential solutions
In my case, I could implement a complex solution similar to bevy's shader system. But that's (1) reinventing the wheel (2) a large burden (3) doesn't solve the problem for other users and use cases.
What I would like to see:
- An alternative to `load_direct` that returns a `Cow` (or a clone of `A`), providing a reference to the asset from the `Assets` store if it is already loaded.
Contributor guide
Assessment
This issue has not been assessed yet.