Skip to content

Commit fc361d5

Browse files
committed
Use type_path in place of type_name where appropriate.
1 parent dd3ae5b commit fc361d5

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

crates/bevy_asset/src/loader.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ pub trait ErasedAssetLoader: Send + Sync + 'static {
6767
fn deserialize_meta(&self, meta: &[u8]) -> Result<Box<dyn AssetMetaDyn>, DeserializeMetaError>;
6868
/// Returns the default meta value for the [`AssetLoader`] (erased as [`Box<dyn AssetMetaDyn>`]).
6969
fn default_meta(&self) -> Box<dyn AssetMetaDyn>;
70-
/// Returns the type name of the [`AssetLoader`].
71-
fn type_name(&self) -> &'static str;
70+
/// Returns the type path of the [`AssetLoader`].
71+
fn type_path(&self) -> &'static str;
7272
/// Returns the [`TypeId`] of the [`AssetLoader`].
7373
fn type_id(&self) -> TypeId;
7474
/// Returns the type name of the top-level [`Asset`] loaded by the [`AssetLoader`].
@@ -112,13 +112,13 @@ where
112112

113113
fn default_meta(&self) -> Box<dyn AssetMetaDyn> {
114114
Box::new(AssetMeta::<L, ()>::new(crate::meta::AssetAction::Load {
115-
loader: self.type_name().to_string(),
115+
loader: self.type_path().to_string(),
116116
settings: L::Settings::default(),
117117
}))
118118
}
119119

120-
fn type_name(&self) -> &'static str {
121-
core::any::type_name::<L>()
120+
fn type_path(&self) -> &'static str {
121+
L::type_path()
122122
}
123123

124124
fn type_id(&self) -> TypeId {

crates/bevy_asset/src/loader_builders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl NestedLoader<'_, '_, StaticTyped, Immediate<'_, '_>> {
467467
path,
468468
requested: TypeId::of::<A>(),
469469
actual_asset_name: loader.asset_type_name(),
470-
loader_name: loader.type_name(),
470+
loader_name: loader.type_path(),
471471
},
472472
})
473473
})

crates/bevy_asset/src/server/loaders.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl<T: AssetLoader> AssetLoader for InstrumentedAssetLoader<T> {
331331
) -> impl ConditionalSendFuture<Output = Result<Self::Asset, Self::Error>> {
332332
let span = info_span!(
333333
"asset loading",
334-
loader = core::any::type_name::<T>(),
334+
loader = T::type_path(),
335335
asset = load_context.asset_path().to_string(),
336336
);
337337
self.0.load(reader, settings, load_context).instrument(span)
@@ -437,7 +437,7 @@ mod tests {
437437

438438
let loader = block_on(
439439
loaders
440-
.get_by_name(Loader::<A, 1, 0>::type_path())
440+
.get_by_name(<Loader<A, 1, 0> as TypePath>::type_path())
441441
.unwrap()
442442
.get(),
443443
)

crates/bevy_asset/src/server/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl AssetServer {
247247
loader.get().await.map_err(|_| error())
248248
}
249249

250-
/// Returns the registered [`AssetLoader`] associated with the given [`core::any::type_name`], if it exists.
250+
/// Returns the registered [`AssetLoader`] associated with the given type name, if it exists.
251251
pub async fn get_asset_loader_with_type_name(
252252
&self,
253253
type_name: &str,
@@ -768,7 +768,7 @@ impl AssetServer {
768768
path: path.into_owned(),
769769
requested: asset_type_id,
770770
actual_asset_name: loader.asset_type_name(),
771-
loader_name: loader.type_name(),
771+
loader_name: loader.type_path(),
772772
});
773773
}
774774
}
@@ -1474,12 +1474,12 @@ impl AssetServer {
14741474
.await
14751475
.map_err(|_| AssetLoadError::AssetLoaderPanic {
14761476
path: asset_path.clone_owned(),
1477-
loader_name: loader.type_name(),
1477+
loader_name: loader.type_path(),
14781478
})?
14791479
.map_err(|e| {
14801480
AssetLoadError::AssetLoaderError(AssetLoaderError {
14811481
path: asset_path.clone_owned(),
1482-
loader_name: loader.type_name(),
1482+
loader_name: loader.type_path(),
14831483
error: e.into(),
14841484
})
14851485
})

0 commit comments

Comments
 (0)