Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add final missing migration guides #1856

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
alice-i-cecile marked this conversation as resolved.
Show resolved Hide resolved

```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
alice-i-cecile marked this conversation as resolved.
Show resolved Hide resolved

```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"