Switch bevy_asset to core::prelude (#17442)
Makes use of `std` explicit, simplifying a possible `no_std` port. # Objective - Contributes to #15460 - Simplify future `no_std` work on `bevy_asset` ## Solution - Add `#![no_std]` to switch to `core::prelude` instead of `std::prelude` ## Testing - CI --- ## Notes This is entirely a change around the names of imports and has no impact on functionality. This just reduces the quantity of changes involved in the (likely more controversial) `no_std`-ification of `bevy_asset`.
This commit is contained in:
parent
5d0e9cfb36
commit
8f32c799ee
@ -288,7 +288,9 @@ unsafe impl<A: AsAssetId> QueryFilter for AssetChanged<A> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{self as bevy_asset, AssetEvents, AssetPlugin, Handle};
|
use crate::{self as bevy_asset, AssetEvents, AssetPlugin, Handle};
|
||||||
|
use alloc::{vec, vec::Vec};
|
||||||
use core::num::NonZero;
|
use core::num::NonZero;
|
||||||
|
use std::println;
|
||||||
|
|
||||||
use crate::{AssetApp, Assets};
|
use crate::{AssetApp, Assets};
|
||||||
use bevy_app::{App, AppExit, Last, Startup, TaskPoolPlugin, Update};
|
use bevy_app::{App, AppExit, Last, Startup, TaskPoolPlugin, Update};
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use crate::{
|
|||||||
self as bevy_asset, Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle,
|
self as bevy_asset, Asset, AssetEvent, AssetHandleProvider, AssetId, AssetServer, Handle,
|
||||||
UntypedHandle,
|
UntypedHandle,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{sync::Arc, vec::Vec};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
prelude::EventWriter,
|
prelude::EventWriter,
|
||||||
system::{Res, ResMut, Resource, SystemChangeTick},
|
system::{Res, ResMut, Resource, SystemChangeTick},
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
use crate as bevy_asset;
|
use crate as bevy_asset;
|
||||||
use crate::{Asset, UntypedHandle};
|
use crate::{Asset, UntypedHandle};
|
||||||
use bevy_reflect::TypePath;
|
use bevy_reflect::TypePath;
|
||||||
|
|||||||
@ -514,6 +514,7 @@ pub enum UntypedAssetConversionError {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use alloc::boxed::Box;
|
||||||
use bevy_reflect::PartialReflect;
|
use bevy_reflect::PartialReflect;
|
||||||
use bevy_utils::FixedHasher;
|
use bevy_utils::FixedHasher;
|
||||||
use core::hash::BuildHasher;
|
use core::hash::BuildHasher;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use crate::io::{get_meta_path, AssetReader, AssetReaderError, PathStream, Reader, VecReader};
|
use crate::io::{get_meta_path, AssetReader, AssetReaderError, PathStream, Reader, VecReader};
|
||||||
|
use alloc::{borrow::ToOwned, boxed::Box, ffi::CString, vec::Vec};
|
||||||
use futures_lite::stream;
|
use futures_lite::stream;
|
||||||
use std::{ffi::CString, path::Path};
|
use std::path::Path;
|
||||||
use tracing::error;
|
|
||||||
|
|
||||||
/// [`AssetReader`] implementation for Android devices, built on top of Android's [`AssetManager`].
|
/// [`AssetReader`] implementation for Android devices, built on top of Android's [`AssetManager`].
|
||||||
///
|
///
|
||||||
@ -72,10 +72,7 @@ impl AssetReader for AndroidAssetReader {
|
|||||||
Ok(read_dir)
|
Ok(read_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn is_directory<'a>(
|
async fn is_directory<'a>(&'a self, path: &'a Path) -> Result<bool, AssetReaderError> {
|
||||||
&'a self,
|
|
||||||
path: &'a Path,
|
|
||||||
) -> std::result::Result<bool, AssetReaderError> {
|
|
||||||
let asset_manager = bevy_window::ANDROID_APP
|
let asset_manager = bevy_window::ANDROID_APP
|
||||||
.get()
|
.get()
|
||||||
.expect("Bevy must be setup with the #[bevy_main] macro on Android")
|
.expect("Bevy must be setup with the #[bevy_main] macro on Android")
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use crate::io::{
|
|||||||
memory::Dir,
|
memory::Dir,
|
||||||
AssetSourceEvent, AssetWatcher,
|
AssetSourceEvent, AssetWatcher,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, RecommendedCache};
|
use notify_debouncer_full::{notify::RecommendedWatcher, Debouncer, RecommendedCache};
|
||||||
|
|||||||
@ -8,9 +8,13 @@ use crate::io::{
|
|||||||
memory::{Dir, MemoryAssetReader, Value},
|
memory::{Dir, MemoryAssetReader, Value},
|
||||||
AssetSource, AssetSourceBuilders,
|
AssetSource, AssetSourceBuilders,
|
||||||
};
|
};
|
||||||
|
use alloc::boxed::Box;
|
||||||
use bevy_ecs::system::Resource;
|
use bevy_ecs::system::Resource;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
#[cfg(feature = "embedded_watcher")]
|
||||||
|
use alloc::borrow::ToOwned;
|
||||||
|
|
||||||
pub const EMBEDDED: &str = "embedded";
|
pub const EMBEDDED: &str = "embedded";
|
||||||
|
|
||||||
/// A [`Resource`] that manages "rust source files" in a virtual in memory [`Dir`], which is intended
|
/// A [`Resource`] that manages "rust source files" in a virtual in memory [`Dir`], which is intended
|
||||||
@ -29,7 +33,7 @@ impl EmbeddedAssetRegistry {
|
|||||||
/// Inserts a new asset. `full_path` is the full path (as [`file`] would return for that file, if it was capable of
|
/// Inserts a new asset. `full_path` is the full path (as [`file`] would return for that file, if it was capable of
|
||||||
/// running in a non-rust file). `asset_path` is the path that will be used to identify the asset in the `embedded`
|
/// running in a non-rust file). `asset_path` is the path that will be used to identify the asset in the `embedded`
|
||||||
/// [`AssetSource`]. `value` is the bytes that will be returned for the asset. This can be _either_ a `&'static [u8]`
|
/// [`AssetSource`]. `value` is the bytes that will be returned for the asset. This can be _either_ a `&'static [u8]`
|
||||||
/// or a [`Vec<u8>`].
|
/// or a [`Vec<u8>`](alloc::vec::Vec).
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
not(feature = "embedded_watcher"),
|
not(feature = "embedded_watcher"),
|
||||||
expect(
|
expect(
|
||||||
@ -48,7 +52,7 @@ impl EmbeddedAssetRegistry {
|
|||||||
/// Inserts new asset metadata. `full_path` is the full path (as [`file`] would return for that file, if it was capable of
|
/// Inserts new asset metadata. `full_path` is the full path (as [`file`] would return for that file, if it was capable of
|
||||||
/// running in a non-rust file). `asset_path` is the path that will be used to identify the asset in the `embedded`
|
/// running in a non-rust file). `asset_path` is the path that will be used to identify the asset in the `embedded`
|
||||||
/// [`AssetSource`]. `value` is the bytes that will be returned for the asset. This can be _either_ a `&'static [u8]`
|
/// [`AssetSource`]. `value` is the bytes that will be returned for the asset. This can be _either_ a `&'static [u8]`
|
||||||
/// or a [`Vec<u8>`].
|
/// or a [`Vec<u8>`](alloc::vec::Vec).
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
not(feature = "embedded_watcher"),
|
not(feature = "embedded_watcher"),
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use async_fs::{read_dir, File};
|
|||||||
use futures_io::AsyncSeek;
|
use futures_io::AsyncSeek;
|
||||||
use futures_lite::StreamExt;
|
use futures_lite::StreamExt;
|
||||||
|
|
||||||
|
use alloc::{borrow::ToOwned, boxed::Box};
|
||||||
use core::{pin::Pin, task, task::Poll};
|
use core::{pin::Pin, task, task::Poll};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use crate::{
|
|||||||
io::{AssetSourceEvent, AssetWatcher},
|
io::{AssetSourceEvent, AssetWatcher},
|
||||||
path::normalize_path,
|
path::normalize_path,
|
||||||
};
|
};
|
||||||
|
use alloc::borrow::ToOwned;
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use crossbeam_channel::Sender;
|
use crossbeam_channel::Sender;
|
||||||
use notify_debouncer_full::{
|
use notify_debouncer_full::{
|
||||||
|
|||||||
@ -10,6 +10,7 @@ mod sync_file_asset;
|
|||||||
pub use file_watcher::*;
|
pub use file_watcher::*;
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
|
use alloc::borrow::ToOwned;
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
|||||||
@ -6,6 +6,7 @@ use crate::io::{
|
|||||||
PathStream, Reader, Writer,
|
PathStream, Reader, Writer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use alloc::{borrow::ToOwned, boxed::Box, vec::Vec};
|
||||||
use core::{pin::Pin, task::Poll};
|
use core::{pin::Pin, task::Poll};
|
||||||
use std::{
|
use std::{
|
||||||
fs::{read_dir, File},
|
fs::{read_dir, File},
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
|
use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
|
||||||
use alloc::sync::Arc;
|
use alloc::{boxed::Box, sync::Arc};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
use crossbeam_channel::{Receiver, Sender};
|
use crossbeam_channel::{Receiver, Sender};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
|
use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
|
||||||
use alloc::sync::Arc;
|
use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
use core::{pin::Pin, task::Poll};
|
use core::{pin::Pin, task::Poll};
|
||||||
use futures_io::AsyncRead;
|
use futures_io::AsyncRead;
|
||||||
|
|||||||
@ -21,7 +21,7 @@ mod source;
|
|||||||
pub use futures_lite::AsyncWriteExt;
|
pub use futures_lite::AsyncWriteExt;
|
||||||
pub use source::*;
|
pub use source::*;
|
||||||
|
|
||||||
use alloc::sync::Arc;
|
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||||
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use core::{
|
use core::{
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use crate::{
|
|||||||
processor::{AssetProcessorData, ProcessStatus},
|
processor::{AssetProcessorData, ProcessStatus},
|
||||||
AssetPath,
|
AssetPath,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec};
|
||||||
use async_lock::RwLockReadGuardArc;
|
use async_lock::RwLockReadGuardArc;
|
||||||
use core::{pin::Pin, task::Poll};
|
use core::{pin::Pin, task::Poll};
|
||||||
use futures_io::AsyncRead;
|
use futures_io::AsyncRead;
|
||||||
|
|||||||
@ -2,7 +2,11 @@ use crate::{
|
|||||||
io::{processor_gated::ProcessorGatedReader, AssetSourceEvent, AssetWatcher},
|
io::{processor_gated::ProcessorGatedReader, AssetSourceEvent, AssetWatcher},
|
||||||
processor::AssetProcessorData,
|
processor::AssetProcessorData,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{
|
||||||
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
use atomicow::CowArc;
|
use atomicow::CowArc;
|
||||||
use bevy_ecs::system::Resource;
|
use bevy_ecs::system::Resource;
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
use crate::io::{
|
use crate::io::{
|
||||||
get_meta_path, AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader,
|
get_meta_path, AssetReader, AssetReaderError, EmptyPathStream, PathStream, Reader, VecReader,
|
||||||
};
|
};
|
||||||
|
use alloc::{borrow::ToOwned, boxed::Box, format};
|
||||||
use js_sys::{Uint8Array, JSON};
|
use js_sys::{Uint8Array, JSON};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|||||||
@ -144,9 +144,10 @@
|
|||||||
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
||||||
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
||||||
)]
|
)]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
extern crate core;
|
extern crate std;
|
||||||
|
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod meta;
|
pub mod meta;
|
||||||
@ -206,7 +207,11 @@ use crate::{
|
|||||||
io::{embedded::EmbeddedAssetRegistry, AssetSourceBuilder, AssetSourceBuilders, AssetSourceId},
|
io::{embedded::EmbeddedAssetRegistry, AssetSourceBuilder, AssetSourceBuilders, AssetSourceId},
|
||||||
processor::{AssetProcessor, Process},
|
processor::{AssetProcessor, Process},
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{
|
||||||
|
string::{String, ToString},
|
||||||
|
sync::Arc,
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use bevy_app::{App, Last, Plugin, PreUpdate};
|
use bevy_app::{App, Last, Plugin, PreUpdate};
|
||||||
use bevy_ecs::prelude::Component;
|
use bevy_ecs::prelude::Component;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
@ -633,7 +638,14 @@ mod tests {
|
|||||||
Asset, AssetApp, AssetEvent, AssetId, AssetLoadError, AssetLoadFailedEvent, AssetPath,
|
Asset, AssetApp, AssetEvent, AssetId, AssetLoadError, AssetLoadFailedEvent, AssetPath,
|
||||||
AssetPlugin, AssetServer, Assets,
|
AssetPlugin, AssetServer, Assets,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{
|
||||||
|
boxed::Box,
|
||||||
|
format,
|
||||||
|
string::{String, ToString},
|
||||||
|
sync::Arc,
|
||||||
|
vec,
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use bevy_app::{App, TaskPoolPlugin, Update};
|
use bevy_app::{App, TaskPoolPlugin, Update};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
event::EventCursor,
|
event::EventCursor,
|
||||||
|
|||||||
@ -6,6 +6,11 @@ use crate::{
|
|||||||
Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, UntypedAssetId,
|
Asset, AssetLoadError, AssetServer, AssetServerMode, Assets, Handle, UntypedAssetId,
|
||||||
UntypedHandle,
|
UntypedHandle,
|
||||||
};
|
};
|
||||||
|
use alloc::{
|
||||||
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use atomicow::CowArc;
|
use atomicow::CowArc;
|
||||||
use bevy_ecs::world::World;
|
use bevy_ecs::world::World;
|
||||||
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use crate::{
|
|||||||
Asset, AssetLoadError, AssetPath, ErasedAssetLoader, ErasedLoadedAsset, Handle, LoadContext,
|
Asset, AssetLoadError, AssetPath, ErasedAssetLoader, ErasedLoadedAsset, Handle, LoadContext,
|
||||||
LoadDirectError, LoadedAsset, LoadedUntypedAsset, UntypedHandle,
|
LoadDirectError, LoadedAsset, LoadedUntypedAsset, UntypedHandle,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{borrow::ToOwned, boxed::Box, sync::Arc};
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
|
|
||||||
// Utility type for handling the sources of reader references
|
// Utility type for handling the sources of reader references
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
use alloc::{
|
||||||
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
self as bevy_asset, loader::AssetLoader, processor::Process, Asset, AssetPath,
|
self as bevy_asset, loader::AssetLoader, processor::Process, Asset, AssetPath,
|
||||||
DeserializeMetaError, VisitAssetDependencies,
|
DeserializeMetaError, VisitAssetDependencies,
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
use crate::io::AssetSourceId;
|
use crate::io::AssetSourceId;
|
||||||
|
use alloc::{
|
||||||
|
borrow::ToOwned,
|
||||||
|
string::{String, ToString},
|
||||||
|
};
|
||||||
use atomicow::CowArc;
|
use atomicow::CowArc;
|
||||||
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
|
||||||
use core::{
|
use core::{
|
||||||
@ -316,7 +320,7 @@ impl<'a> AssetPath<'a> {
|
|||||||
/// If internally a value is a static reference, the static reference will be used unchanged.
|
/// If internally a value is a static reference, the static reference will be used unchanged.
|
||||||
/// If internally a value is an "owned [`Arc`]", it will remain unchanged.
|
/// If internally a value is an "owned [`Arc`]", it will remain unchanged.
|
||||||
///
|
///
|
||||||
/// [`Arc`]: std::sync::Arc
|
/// [`Arc`]: alloc::sync::Arc
|
||||||
pub fn into_owned(self) -> AssetPath<'static> {
|
pub fn into_owned(self) -> AssetPath<'static> {
|
||||||
AssetPath {
|
AssetPath {
|
||||||
source: self.source.into_owned(),
|
source: self.source.into_owned(),
|
||||||
@ -329,7 +333,7 @@ impl<'a> AssetPath<'a> {
|
|||||||
/// If internally a value is a static reference, the static reference will be used unchanged.
|
/// If internally a value is a static reference, the static reference will be used unchanged.
|
||||||
/// If internally a value is an "owned [`Arc`]", the [`Arc`] will be cloned.
|
/// If internally a value is an "owned [`Arc`]", the [`Arc`] will be cloned.
|
||||||
///
|
///
|
||||||
/// [`Arc`]: std::sync::Arc
|
/// [`Arc`]: alloc::sync::Arc
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn clone_owned(&self) -> AssetPath<'static> {
|
pub fn clone_owned(&self) -> AssetPath<'static> {
|
||||||
self.clone().into_owned()
|
self.clone().into_owned()
|
||||||
@ -629,6 +633,7 @@ pub(crate) fn normalize_path(path: &Path) -> PathBuf {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::AssetPath;
|
use crate::AssetPath;
|
||||||
|
use alloc::string::ToString;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
use crate::AssetPath;
|
use crate::AssetPath;
|
||||||
|
use alloc::{
|
||||||
|
format,
|
||||||
|
string::{String, ToString},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use async_fs::File;
|
use async_fs::File;
|
||||||
use bevy_utils::HashSet;
|
use bevy_utils::HashSet;
|
||||||
use futures_lite::{AsyncReadExt, AsyncWriteExt};
|
use futures_lite::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
|||||||
@ -56,10 +56,8 @@ use crate::{
|
|||||||
AssetLoadError, AssetMetaCheck, AssetPath, AssetServer, AssetServerMode, DeserializeMetaError,
|
AssetLoadError, AssetMetaCheck, AssetPath, AssetServer, AssetServerMode, DeserializeMetaError,
|
||||||
MissingAssetLoaderForExtensionError,
|
MissingAssetLoaderForExtensionError,
|
||||||
};
|
};
|
||||||
use alloc::{collections::VecDeque, sync::Arc};
|
use alloc::{borrow::ToOwned, boxed::Box, collections::VecDeque, sync::Arc, vec, vec::Vec};
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
#[cfg(feature = "trace")]
|
|
||||||
use bevy_tasks::ConditionalSendFuture;
|
|
||||||
use bevy_tasks::IoTaskPool;
|
use bevy_tasks::IoTaskPool;
|
||||||
use bevy_utils::{HashMap, HashSet};
|
use bevy_utils::{HashMap, HashSet};
|
||||||
use futures_io::ErrorKind;
|
use futures_io::ErrorKind;
|
||||||
@ -68,8 +66,13 @@ use parking_lot::RwLock;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tracing::{debug, error, trace, warn};
|
use tracing::{debug, error, trace, warn};
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
use tracing::{info_span, instrument::Instrument};
|
use {
|
||||||
|
alloc::string::ToString,
|
||||||
|
bevy_tasks::ConditionalSendFuture,
|
||||||
|
tracing::{info_span, instrument::Instrument},
|
||||||
|
};
|
||||||
|
|
||||||
/// A "background" asset processor that reads asset values from a source [`AssetSource`] (which corresponds to an [`AssetReader`](crate::io::AssetReader) / [`AssetWriter`](crate::io::AssetWriter) pair),
|
/// A "background" asset processor that reads asset values from a source [`AssetSource`] (which corresponds to an [`AssetReader`](crate::io::AssetReader) / [`AssetWriter`](crate::io::AssetWriter) pair),
|
||||||
/// processes them in some way, and writes them to a destination [`AssetSource`].
|
/// processes them in some way, and writes them to a destination [`AssetSource`].
|
||||||
|
|||||||
@ -10,6 +10,11 @@ use crate::{
|
|||||||
AssetLoadError, AssetLoader, AssetPath, DeserializeMetaError, ErasedLoadedAsset,
|
AssetLoadError, AssetLoader, AssetPath, DeserializeMetaError, ErasedLoadedAsset,
|
||||||
MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError,
|
MissingAssetLoaderForExtensionError, MissingAssetLoaderForTypeNameError,
|
||||||
};
|
};
|
||||||
|
use alloc::{
|
||||||
|
borrow::ToOwned,
|
||||||
|
boxed::Box,
|
||||||
|
string::{String, ToString},
|
||||||
|
};
|
||||||
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
use alloc::boxed::Box;
|
||||||
use core::any::{Any, TypeId};
|
use core::any::{Any, TypeId};
|
||||||
|
|
||||||
use bevy_ecs::world::{unsafe_world_cell::UnsafeWorldCell, World};
|
use bevy_ecs::world::{unsafe_world_cell::UnsafeWorldCell, World};
|
||||||
@ -243,6 +244,7 @@ impl<A: Asset> FromType<Handle<A>> for ReflectHandle {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use alloc::{string::String, vec::Vec};
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
|
|
||||||
use crate as bevy_asset;
|
use crate as bevy_asset;
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use crate::{
|
|||||||
io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader,
|
io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader,
|
||||||
ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle,
|
ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle,
|
||||||
};
|
};
|
||||||
|
use alloc::boxed::Box;
|
||||||
use atomicow::CowArc;
|
use atomicow::CowArc;
|
||||||
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
use bevy_tasks::{BoxedFuture, ConditionalSendFuture};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
|||||||
@ -4,7 +4,12 @@ use crate::{
|
|||||||
Handle, InternalAssetEvent, LoadState, RecursiveDependencyLoadState, StrongHandle,
|
Handle, InternalAssetEvent, LoadState, RecursiveDependencyLoadState, StrongHandle,
|
||||||
UntypedAssetId, UntypedHandle,
|
UntypedAssetId, UntypedHandle,
|
||||||
};
|
};
|
||||||
use alloc::sync::{Arc, Weak};
|
use alloc::{
|
||||||
|
borrow::ToOwned,
|
||||||
|
boxed::Box,
|
||||||
|
sync::{Arc, Weak},
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use bevy_ecs::world::World;
|
use bevy_ecs::world::World;
|
||||||
use bevy_tasks::Task;
|
use bevy_tasks::Task;
|
||||||
use bevy_utils::{Entry, HashMap, HashSet, TypeIdMap};
|
use bevy_utils::{Entry, HashMap, HashSet, TypeIdMap};
|
||||||
|
|||||||
@ -2,17 +2,20 @@ use crate::{
|
|||||||
loader::{AssetLoader, ErasedAssetLoader},
|
loader::{AssetLoader, ErasedAssetLoader},
|
||||||
path::AssetPath,
|
path::AssetPath,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||||
use async_broadcast::RecvError;
|
use async_broadcast::RecvError;
|
||||||
#[cfg(feature = "trace")]
|
|
||||||
use bevy_tasks::ConditionalSendFuture;
|
|
||||||
use bevy_tasks::IoTaskPool;
|
use bevy_tasks::IoTaskPool;
|
||||||
use bevy_utils::{HashMap, TypeIdMap};
|
use bevy_utils::{HashMap, TypeIdMap};
|
||||||
use core::any::TypeId;
|
use core::any::TypeId;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
#[cfg(feature = "trace")]
|
#[cfg(feature = "trace")]
|
||||||
use tracing::{info_span, instrument::Instrument};
|
use {
|
||||||
|
alloc::string::ToString,
|
||||||
|
bevy_tasks::ConditionalSendFuture,
|
||||||
|
tracing::{info_span, instrument::Instrument},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(crate) struct AssetLoaders {
|
pub(crate) struct AssetLoaders {
|
||||||
@ -338,6 +341,7 @@ impl<T: AssetLoader> AssetLoader for InstrumentedAssetLoader<T> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use alloc::{format, string::String};
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use std::{
|
use std::{
|
||||||
path::Path,
|
path::Path,
|
||||||
|
|||||||
@ -17,7 +17,12 @@ use crate::{
|
|||||||
DeserializeMetaError, ErasedLoadedAsset, Handle, LoadedUntypedAsset, UntypedAssetId,
|
DeserializeMetaError, ErasedLoadedAsset, Handle, LoadedUntypedAsset, UntypedAssetId,
|
||||||
UntypedAssetLoadFailedEvent, UntypedHandle,
|
UntypedAssetLoadFailedEvent, UntypedHandle,
|
||||||
};
|
};
|
||||||
use alloc::sync::Arc;
|
use alloc::{borrow::ToOwned, boxed::Box, vec, vec::Vec};
|
||||||
|
use alloc::{
|
||||||
|
format,
|
||||||
|
string::{String, ToString},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
use atomicow::CowArc;
|
use atomicow::CowArc;
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_tasks::IoTaskPool;
|
use bevy_tasks::IoTaskPool;
|
||||||
@ -198,7 +203,7 @@ impl AssetServer {
|
|||||||
loader.ok_or_else(error)?.get().await.map_err(|_| error())
|
loader.ok_or_else(error)?.get().await.map_err(|_| error())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the registered [`AssetLoader`] associated with the given [`std::any::type_name`], if it exists.
|
/// Returns the registered [`AssetLoader`] associated with the given [`core::any::type_name`], if it exists.
|
||||||
pub async fn get_asset_loader_with_type_name(
|
pub async fn get_asset_loader_with_type_name(
|
||||||
&self,
|
&self,
|
||||||
type_name: &str,
|
type_name: &str,
|
||||||
@ -1472,7 +1477,8 @@ impl AssetServer {
|
|||||||
pub fn handle_internal_asset_events(world: &mut World) {
|
pub fn handle_internal_asset_events(world: &mut World) {
|
||||||
world.resource_scope(|world, server: Mut<AssetServer>| {
|
world.resource_scope(|world, server: Mut<AssetServer>| {
|
||||||
let mut infos = server.data.infos.write();
|
let mut infos = server.data.infos.write();
|
||||||
let mut untyped_failures = vec![];
|
let var_name = vec![];
|
||||||
|
let mut untyped_failures = var_name;
|
||||||
for event in server.data.asset_event_receiver.try_iter() {
|
for event in server.data.asset_event_receiver.try_iter() {
|
||||||
match event {
|
match event {
|
||||||
InternalAssetEvent::Loaded { id, loaded_asset } => {
|
InternalAssetEvent::Loaded { id, loaded_asset } => {
|
||||||
@ -1812,7 +1818,7 @@ pub struct MissingAssetLoaderForExtensionError {
|
|||||||
extensions: Vec<String>,
|
extensions: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that occurs when an [`AssetLoader`] is not registered for a given [`std::any::type_name`].
|
/// An error that occurs when an [`AssetLoader`] is not registered for a given [`core::any::type_name`].
|
||||||
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
||||||
#[error("no `AssetLoader` found with the name '{type_name}'")]
|
#[error("no `AssetLoader` found with the name '{type_name}'")]
|
||||||
pub struct MissingAssetLoaderForTypeNameError {
|
pub struct MissingAssetLoaderForTypeNameError {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
use crate::{meta::Settings, Asset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle};
|
use crate::{meta::Settings, Asset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle};
|
||||||
|
use alloc::boxed::Box;
|
||||||
use atomicow::CowArc;
|
use atomicow::CowArc;
|
||||||
use bevy_tasks::ConditionalSendFuture;
|
use bevy_tasks::ConditionalSendFuture;
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user