-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add final missing migration guides (#1856)
Co-authored-by: Rich Churcher <[email protected]>
- Loading branch information
1 parent
93aa1bc
commit f9f4d27
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...tent/0.15/migration-guides/14082_AssetReader_read_now_returns_an_opaque_type.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
``` |
2 changes: 2 additions & 0 deletions
2
...se-content/0.15/migration-guides/15090_Deprecate_LoadAndSave_Asset_Processor.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters