Change images data field from Vec<u8> to Cow<'static, [u8]>
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Distributing single binaries is really convenient and somnetimes a very efficient solution. The core question is wether the data field actually has to be a `Vec` or if it could be replaced with a `Cow` which spares memory allocation if the data is already inside the binary.
## What solution would you like?
Optimally one would replace the data field with a `Cow<'static, [u8]>` and fits other functions that need to mutate the buffer to use `Cow::to_mut`
## What alternative(s) have you considered?
This seems to be a rather "niche" case but it could add a lot of value, espacially for "default"/fallback textures.
## Additional context
Generally loading Assets without the `AssetServer` is quite a hassle in my opinion, the documentation on how to create the assets could be improved or there could be a embedded assets asset server io based on `rust_embed`, but then there would also need to be an easy way to swap the `AssetIo` of the `AssetServer`.
Contributor guide
Research direction
Start by locating the images data field and every function that reads or mutates its buffer. Review the default or fallback texture paths and the issue's embedded-asset context; done means the representation supports borrowed static data while mutation paths still work without breaking image loading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics, game-dev
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100