Skip to content

Commit

Permalink
Add final missing migration guides (#1856)
Browse files Browse the repository at this point in the history
Co-authored-by: Rich Churcher <[email protected]>
  • Loading branch information
alice-i-cecile and bas-ie authored Nov 27, 2024
1 parent 93aa1bc commit f9f4d27
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
The trait method `bevy_asset::io::AssetReader::read` (and `read_meta`) now return an opaque type instead of a boxed trait object. Implementors of these methods should change the type signatures appropriately:

```rust
impl AssetReader for MyReader {
// Before
async fn read<'a>(&'a self, path: &'a Path) -> Result<Box<Reader<'a>>, AssetReaderError> {
let reader = // construct a reader
Box::new(reader) as Box<Reader<'a>>
}

// After
async fn read<'a>(&'a self, path: &'a Path) -> Result<impl Reader + 'a, AssetReaderError> {
// create a reader
}
}
```

`bevy::asset::io::Reader` is now a trait, rather than a type alias for a trait object. Implementors of `AssetLoader::load` will need to adjust the method signature accordingly:

```rust
impl AssetLoader for MyLoader {
async fn load<'a>(
&'a self,
// Before:
reader: &'a mut bevy::asset::io::Reader,
// After:
reader: &'a mut dyn bevy::asset::io::Reader,
_: &'a Self::Settings,
load_context: &'a mut LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
}
```

Additionally, implementors of `AssetReader` that return a type implementing `futures_io::AsyncRead` and `AsyncSeek` might need to explicitly implement `bevy::asset::io::Reader` for that type.

```rust
impl bevy::asset::io::Reader for MyAsyncReadAndSeek {}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Replace `LoadAndSave<L, S>` with `LoadTransformAndSave<L, IdentityAssetTransformer<<L as AssetLoader>::Asset>, S>`
- Replace `LoadAndSaveSettings<L, S>` with `LoadTransformAndSaveSettings<L, (), S>`
14 changes: 13 additions & 1 deletion release-content/0.15/migration-guides/_guides.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1315,5 +1315,17 @@ file_name = "13760_Add_Display_implementation_to_DebugName.md"
[[guides]]
title = "Remove `accesskit` re-export from `bevy_a11y`"
prs = [16257]
areas = []
areas = ["Accessibility"]
file_name = "16257_Remove_accesskit_reexport_from_bevy_a11y.md"

[[guides]]
title = "Deprecate `LoadAndSave` Asset Processor"
prs = [15090]
areas = ["Asset"]
file_name = "15090_Deprecate_LoadAndSave_Asset_Processor.md"

[[guides]]
title = "`AssetReader::read` now returns an opaque type"
prs = [14082]
areas = ["Asset"]
file_name = "14082_AssetReader_read_now_returns_an_opaque_type.md"

0 comments on commit f9f4d27

Please sign in to comment.