#Hey bevy people! Im having trouble with migrating my asset loader from 0.14 to 0.15

6 messages · Page 1 of 1 (latest)

native zinc
#

Previously, I had this code:

impl AssetLoader for MapAssetLoader {
    type Asset = MapAsset;
    type Settings = ();
    type Error = MapAssetLoaderError;
    async fn load<'a>(
        &'a self,
        reader: &'a mut Reader<'_>,
        _settings: &'a Self::Settings,
        load_context: &'a mut LoadContext<'_>,
    ) -> Result<Self::Asset, Self::Error> {
        load::load(reader, load_context, false).await
    }

    fn extensions(&self) -> &[&str] {
        &["map"]
    }
}

And i get an error regarding the function signature. After consulting the change logs, I saw Reader became a trait, so i changed my function as such, as recommended by the docs:

  async fn load<'a>(
      &'a self,
      reader: &'a dyn Reader,
      _settings: &'a Self::Settings,
      load_context: &'a mut LoadContext<'_>,
  ) -> Result<Self::Asset, Self::Error> {
      load::load(reader, load_context, false).await
  }

However, This still produces multiple compiler errors:

  • LoadContext's reference lifetime lives longer than the data, which makes sense since 'a lives longer than '_. But the docs dont say to do this so i dont know
  • The load function signature isnt correct (the error for this is wayy to long and verbose)

Any help would be very much appreciated, thanks in advace! :D

#

(Also im aware of the confusion, load is a seperate crate which i store all of my actual loading impl in)

#
pub(crate) async fn load<'a>(
    reader: &'a mut dyn Reader,
    load_context: &'a mut LoadContext<'_>,
    headless: bool,
) -> Result<MapAsset, MapAssetLoaderError> {
  //....
}

this is said loading function

#

Ok i found the issue and i am to blame for not reading all of the migration guide

#

if you just drop the 'a everywhere it works :D