bevy-website
bevy-website copied to clipboard
AssetReader is missing in the upgrade guides
How can Bevy's documentation be improved?
in any of the following (not sure which) https://bevyengine.org/learn/migration-guides/0-10-to-0-11/ https://bevyengine.org/learn/migration-guides/0-11-to-0-12/ https://bevyengine.org/learn/migration-guides/0-12-to-0-13/ there is missing the 'AssetReader' It was completely changed since 0.10.0 See here: https://bevyengine.org/examples/Assets/custom-asset-reader/ formerly it was called AssetIo Also the signature of the read function changed:
xpected `{async block@src\asset_server_plugin.rs:53:23: 66:5}` to be a future that resolves to `Result<Box<dyn AsyncRead + Send + Sync + Unpin>, AssetReaderError>`, but it resolves to `Result<Vec<u8>, AssetReaderError>`
It is now in WASM the same as in non-WASM
Sorry if I ask, but it took me 3 weeks to get this implemented. I am relatively new to rust and had too read into assosiated types, Send, async, Pin, move, Futures, Javascript closures, the whole bindgen and web-assembly topics
If there is someone who can help me how I adopt my read function in impl AssetReader for CustomAssetReader
:
fn read<'a>(&'a self,path: &'a Path) -> BoxedFuture<'a, Result<Box<Reader<'a>>, AssetReaderError>> {
// if we are on wasm then get asset by ID from asset server
#[cfg(target_arch = "wasm32")] {
let result = load_asset(path);
let res = Box::pin(async move {
// Call the asynchronous function directly
let result = result.await;
result.map(|data| {
let d = data.unwrap_or_else(|| Vec::<u8>::new());
log::info!("unwrapped: {}", data_to_string(&d));
d
}) // Handle None case if needed
.map_err(|error| {
log::info!("map-error!!!!!!!! {:?}", error);
AssetReaderError::NotFound(path_str.into())
}) });
return res;
}
This worked in bevy 0.10.0 (with the old function name of course) It now gives me the above error, so I understand that it (something) has to implement "AsyncRead + Send + Sync + Unpin". But I don't know how. Back then I asked on the discord server but never got any anwer