bevy/crates/bevy_asset/src
robtfm 5581926ad3 derive asset for enums (#10410)
# Objective

allow deriving `Asset` for enums, and for tuple structs.

## Solution

add to the proc macro, generating visitor calls to the variant's data
(if required).

supports unnamed or named field variants, and struct variants when the
struct also derives `Asset`:
```rust
#[derive(Asset, TypePath)]
pub enum MyAssetEnum {
    Unnamed (
        #[dependency]
        Handle<Image>
    ),
    Named {
        #[dependency]
        array_handle: Handle<Image>,
        #[dependency]
        atlas_handles: Vec<Handle<Image>>,
    },
    StructStyle(
        #[dependency]
        VariantStruct
    ),
    Empty,
}

#[derive(Asset, TypePath)]
pub struct VariantStruct {
    // ...
}
```

also extend the struct implementation to support tuple structs: 
```rust
#[derive(Asset, TypePath)]
pub struct MyImageNewtype(
    #[dependency]
    Handle<Image>
);
````

---------

Co-authored-by: Nicola Papale <nico@nicopap.ch>
2023-11-29 16:52:50 -08:00
..
io Do not panic when failing to create assets folder (#10613) (#10614) 2023-11-29 16:47:36 -08:00
processor Make AssetLoader/Saver Error type bounds compatible with anyhow::Error (#10493) 2023-11-29 16:41:48 -08:00
server Add missing asset load error logs for load_folder and load_untyped (#10578) 2023-11-29 16:46:21 -08:00
assets.rs Non-blocking load_untyped using a wrapper asset (#10198) 2023-10-26 22:14:32 +00:00
event.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
folder.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
handle.rs Asset v2: Asset path serialization fix (#9756) 2023-09-13 05:43:01 +00:00
id.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
lib.rs derive asset for enums (#10410) 2023-11-29 16:52:50 -08:00
loader.rs Add load_untyped to LoadContext (#10526) 2023-11-29 16:45:37 -08:00
meta.rs assets: use blake3 instead of md5 (#10208) 2023-10-23 04:15:04 +00:00
path.rs Don't .unwrap() in AssetPath::try_parse (#10452) 2023-11-29 16:40:48 -08:00
reflect.rs Bevy Asset V2 (#8624) 2023-09-07 02:07:27 +00:00
saver.rs Make AssetLoader/Saver Error type bounds compatible with anyhow::Error (#10493) 2023-11-29 16:41:48 -08:00