mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix voxygen compilation without plugins, part 2
This commit is contained in:
@ -123,7 +123,6 @@ pub trait AssetExt: Sized + Send + Sync + 'static {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extension to AssetExt to combine Ron files from filesystem and plugins
|
/// Extension to AssetExt to combine Ron files from filesystem and plugins
|
||||||
#[cfg(feature = "plugins")]
|
|
||||||
pub trait AssetCombined: AssetExt {
|
pub trait AssetCombined: AssetExt {
|
||||||
fn load_and_combine(specifier: &str) -> Result<AssetHandle<Self>, BoxedError>;
|
fn load_and_combine(specifier: &str) -> Result<AssetHandle<Self>, BoxedError>;
|
||||||
|
|
||||||
@ -140,7 +139,6 @@ pub trait AssetCombined: AssetExt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extension to AnyCache to combine Ron files from filesystem and plugins
|
/// Extension to AnyCache to combine Ron files from filesystem and plugins
|
||||||
#[cfg(feature = "plugins")]
|
|
||||||
pub trait CacheCombined<'a> {
|
pub trait CacheCombined<'a> {
|
||||||
fn load_and_combine<A: Compound + Concatenate>(
|
fn load_and_combine<A: Compound + Concatenate>(
|
||||||
self,
|
self,
|
||||||
@ -201,28 +199,33 @@ impl<T: Compound> AssetExt for T {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "plugins")]
|
|
||||||
impl<'a> CacheCombined<'a> for AnyCache<'a> {
|
impl<'a> CacheCombined<'a> for AnyCache<'a> {
|
||||||
fn load_and_combine<A: Compound + Concatenate>(
|
fn load_and_combine<A: Compound + Concatenate>(
|
||||||
self,
|
self,
|
||||||
specifier: &str,
|
specifier: &str,
|
||||||
) -> Result<assets_manager::Handle<'a, A>, BoxedError> {
|
) -> Result<assets_manager::Handle<'a, A>, BoxedError> {
|
||||||
self.get_cached(specifier).map_or_else(
|
#[cfg(feature = "plugins")]
|
||||||
|| {
|
{
|
||||||
// only create this combined object if is not yet cached
|
self.get_cached(specifier).map_or_else(
|
||||||
let id_bytes = SharedBytes::from_slice(specifier.as_bytes());
|
|| {
|
||||||
// as it was created from UTF8 it needs to be valid UTF8
|
// only create this combined object if is not yet cached
|
||||||
let id = SharedString::from_utf8(id_bytes).unwrap();
|
let id_bytes = SharedBytes::from_slice(specifier.as_bytes());
|
||||||
tracing::info!("combine {specifier}");
|
// as it was created from UTF8 it needs to be valid UTF8
|
||||||
let data: Result<A, _> = ASSETS.combine(|cache: AnyCache| A::load(cache, &id));
|
let id = SharedString::from_utf8(id_bytes).unwrap();
|
||||||
data.map(|data| self.get_or_insert(specifier, data))
|
tracing::info!("combine {specifier}");
|
||||||
},
|
let data: Result<A, _> = ASSETS.combine(|cache: AnyCache| A::load(cache, &id));
|
||||||
Ok,
|
data.map(|data| self.get_or_insert(specifier, data))
|
||||||
)
|
},
|
||||||
|
Ok,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "plugins"))]
|
||||||
|
{
|
||||||
|
Ok(self.load(specifier)?)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "plugins")]
|
|
||||||
impl<T: Compound + Concatenate> AssetCombined for T {
|
impl<T: Compound + Concatenate> AssetCombined for T {
|
||||||
fn load_and_combine(specifier: &str) -> Result<AssetHandle<Self>, BoxedError> {
|
fn load_and_combine(specifier: &str) -> Result<AssetHandle<Self>, BoxedError> {
|
||||||
ASSETS.as_any_cache().load_and_combine(specifier)
|
ASSETS.as_any_cache().load_and_combine(specifier)
|
||||||
|
Reference in New Issue
Block a user