bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Document practical differences between the two `HandleId` variants

Open oddfacade opened this issue 2 years ago • 1 comments

Docs say HandleId::Id is "a handle id of a loaded asset" while HandleId::AssetPathId is "a handle id of a pending asset" but it is not immediately clear what this actually means, since a pending asset will presumably turn into a loaded asset at some point.

Here are a few questions I think it would be helpful for the documentation to answer:

  • Under what conditions will the asset server return one vs the other?
  • How is each used internally?
  • HandleId::Id stores a type id, but HandleId::AssetPathId does not. What are the implications of this? For instance, HandleUntyped::typed claims to panic if the type is wrong but this is only true if its handle id is the former variant.
  • Why does AssetServer::get_load_state return LoadState::NotLoaded unconditionally if you give it what is ostensibly "the handle id of a loaded asset"?

oddfacade avatar Oct 01 '22 19:10 oddfacade

Why does AssetServer::get_load_state return LoadState::NotLoaded unconditionally if you give it what is ostensibly "the handle id of a loaded asset"?

I think this is because of how Eq is implemented for Handle. It just compares the HandleId, which can be either HandleId::AssetPathId or HandleId::Id, so even if an id is supposed to point to the same asset it may not be considered equal :/

tim-blackbird avatar Oct 01 '22 19:10 tim-blackbird

This type (or anything remotely resembling it AFAICT) no longer exists as of Assets v2.

ItsDoot avatar Jul 27 '24 03:07 ItsDoot