bevy/crates/bevy_gltf
andriyDev 723b52abd3
Allow returning an error from labeled_asset_scope. (#19449)
# Objective

- `LoadContext::labeled_asset_scope` cannot return errors back to the
asset loader. This means users that need errors need to fall back to
using the raw `begin_labeled_asset` and `add_loaded_labeled_asset`,
which is more error-prone.

## Solution

- Allow returning a (generic) error from `labeled_asset_scope`.
- This has the unfortunate side effect that closures which don't return
any errors need to A) return Ok at the end, B) need to specify an error
type (e.g., `()`).

---

## Showcase

```rust
// impl AssetLoader for MyLoader
let handle = load_context.labeled_asset_scope("MySubasset", |mut load_context| {
  if !some_precondition {
    return Err(ThingsDontMakeSenseError);
  }
  let handle = load_context.add_labeled_asset("MySubasset/Other", SomeOtherThing(456));
  Ok(Something{ id: 123, handle })
})?;
```
2025-06-04 00:00:32 +00:00
..
src Allow returning an error from labeled_asset_scope. (#19449) 2025-06-04 00:00:32 +00:00
Cargo.toml Make sure that serde_json::Map::into_values exists (#19229) 2025-05-26 19:38:28 +00:00
LICENSE-APACHE Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
LICENSE-MIT Cleanup publish process (#17728) 2025-02-09 17:46:19 +00:00
README.md

Bevy glTF

License Crates.io Downloads Docs Discord