bevy/crates
Ludwig DUBOS 611ba8b98e
Add AsyncSeekForwardExt trait to allows a similar API to the previous Bevy version (#16027)
# Objective

This PR introduces an `AsyncSeekForwardExt` trait, which I forgot in my
previous PR #14194.

This new trait is analogous to `AsyncSeekExt` and allows all
implementors of `AsyncSeekForward` to directly use the `seek_forward`
function in async contexts.

## Solution

- Implement a new `AsyncSeekForwardExt` trait
- Automatically implement this trait for all types that implement
`AsyncSeekForward`

## Showcase

This new trait allows a similar API to the previous Bevy version:

```rust
#[derive(Default)]
struct UniverseLoader;

#[derive(Asset, TypePath, Debug)]
struct JustALilAsteroid([u8; 128]);

impl AssetLoader for UniverseLoader {
    type Asset = JustALilAsteroid;
    type Settings = ();
    type Error = std::io::Error;

    async fn load<'a>(
        &'a self,
        reader: &'a mut Reader<'a>,
        _settings: &'a Self::Settings,
        _context: &'a mut LoadContext<'_>,
    ) -> Result<Self::Asset, Self::Error> {
        // read the asteroids entry table
        let entry_offset: u64 = /* ... */;
        let current_offset: u64 = reader.seek_forward(0).await?;

        // jump to the entry
        reader.seek_forward(entry_offset - current_offset).await?;

        let mut asteroid_buf = [0; 128];
        reader.read_exact(&mut asteroid_buf).await?;

        Ok(JustALilAsteroid(asteroid_buf))
    }
    
    fn extensions(&self) -> &[&str] {
        &["celestial"]
    }
}
```
2024-10-25 20:08:14 +00:00
..
bevy_a11y Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_animation Replace TwoIterators with Either in bevy_animation (#16036) 2024-10-21 02:17:59 +00:00
bevy_app Migrate from Query::single and friends to Single (#15872) 2024-10-13 20:32:06 +00:00
bevy_asset Add AsyncSeekForwardExt trait to allows a similar API to the previous Bevy version (#16027) 2024-10-25 20:08:14 +00:00
bevy_audio Fix audio not playing (#15638) 2024-10-04 01:07:09 +00:00
bevy_color Fix bevy_color not compiling standalone. (#15938) 2024-10-15 23:52:45 +00:00
bevy_core Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_core_pipeline Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_derive move ANDROID_APP to bevy_window (#15585) 2024-10-02 03:01:06 +00:00
bevy_dev_tools Merge Style properties into Node. Use ComputedNode for computed properties. (#15975) 2024-10-18 22:25:33 +00:00
bevy_diagnostic Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_encase_derive Update `glam to 0.29, encase` to 0.10. (#15249) 2024-09-23 19:44:02 +00:00
bevy_gilrs Remove thiserror from bevy_gilrs (#15773) 2024-10-09 14:21:25 +00:00
bevy_gizmos Fix gizmos (#15836) 2024-10-10 22:04:04 +00:00
bevy_gltf Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_hierarchy fix: add reflect to SceneInstanceReady and other observers/events (#16018) 2024-10-20 13:51:41 +00:00
bevy_image Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_input Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_internal Place percentage-closer soft shadows behind a feature gate to save on samplers. (#16068) 2024-10-24 21:16:00 +00:00
bevy_log Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_macro_utils Modify derive_label to support no_std environments (#15465) 2024-09-27 20:23:26 +00:00
bevy_math Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_mesh Add a test for Mesh::triangles and fix for TriangleStrip (#16026) 2024-10-21 15:57:52 +00:00
bevy_mikktspace Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_pbr Place percentage-closer soft shadows behind a feature gate to save on samplers. (#16068) 2024-10-24 21:16:00 +00:00
bevy_picking fix: add reflect to SceneInstanceReady and other observers/events (#16018) 2024-10-20 13:51:41 +00:00
bevy_ptr Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_reflect Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_remote remove reference to missing file in bevy_remote cargo.toml (#16057) 2024-10-22 20:21:19 +00:00
bevy_render Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_scene fix: add reflect to SceneInstanceReady and other observers/events (#16018) 2024-10-20 13:51:41 +00:00
bevy_sprite Move TextureAtlas into UiImage and remove impl Component for TextureAtlas (#16072) 2024-10-23 23:24:17 +00:00
bevy_state Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_tasks Resolve unused_qualifications warnings (#16001) 2024-10-19 16:59:58 +00:00
bevy_text Use CosmicFontSystem in public bevy_text APIs and remove cosmic_text re-export (#16063) 2024-10-23 20:05:28 +00:00
bevy_time Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_transform Remove thiserror from bevy_transform (#15761) 2024-10-09 14:27:30 +00:00
bevy_ui Move TextureAtlas into UiImage and remove impl Component for TextureAtlas (#16072) 2024-10-23 23:24:17 +00:00
bevy_utils Fix detailed_trace module scope (#15912) 2024-10-15 02:48:36 +00:00
bevy_window Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_winit fix: add reflect to SceneInstanceReady and other observers/events (#16018) 2024-10-20 13:51:41 +00:00