Merge 9c19f86fbb
into f964ee1e3a
This commit is contained in:
commit
eedcc4df56
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
#[cfg(feature = "embedded_watcher")]
|
||||
mod embedded_watcher;
|
||||
|
||||
@ -139,6 +141,7 @@ impl EmbeddedAssetRegistry {
|
||||
///
|
||||
/// [`load_embedded_asset!`]: crate::load_embedded_asset
|
||||
pub trait GetAssetServer {
|
||||
/// TODO
|
||||
fn get_asset_server(&self) -> &AssetServer;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
#[cfg(feature = "file_watcher")]
|
||||
mod file_watcher;
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
//!
|
||||
use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
|
||||
use alloc::{boxed::Box, sync::Arc};
|
||||
use bevy_platform::collections::HashMap;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
use crate::io::{AssetReader, AssetReaderError, PathStream, Reader};
|
||||
use alloc::{borrow::ToOwned, boxed::Box, sync::Arc, vec::Vec};
|
||||
use bevy_platform::collections::HashMap;
|
||||
@ -31,14 +33,17 @@ impl Dir {
|
||||
})))
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn insert_asset_text(&self, path: &Path, asset: &str) {
|
||||
self.insert_asset(path, asset.as_bytes().to_vec());
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn insert_meta_text(&self, path: &Path, asset: &str) {
|
||||
self.insert_meta(path, asset.as_bytes().to_vec());
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn insert_asset(&self, path: &Path, value: impl Into<Value>) {
|
||||
let mut dir = self.clone();
|
||||
if let Some(parent) = path.parent() {
|
||||
@ -63,6 +68,7 @@ impl Dir {
|
||||
dir.0.write().assets.remove(&key)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn insert_meta(&self, path: &Path, value: impl Into<Value>) {
|
||||
let mut dir = self.clone();
|
||||
if let Some(parent) = path.parent() {
|
||||
@ -77,6 +83,7 @@ impl Dir {
|
||||
);
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn get_or_insert_dir(&self, path: &Path) -> Dir {
|
||||
let mut dir = self.clone();
|
||||
let mut full_path = PathBuf::new();
|
||||
@ -94,6 +101,7 @@ impl Dir {
|
||||
dir
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn get_dir(&self, path: &Path) -> Option<Dir> {
|
||||
let mut dir = self.clone();
|
||||
for p in path.components() {
|
||||
@ -104,6 +112,7 @@ impl Dir {
|
||||
Some(dir)
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn get_asset(&self, path: &Path) -> Option<Data> {
|
||||
let mut dir = self.clone();
|
||||
if let Some(parent) = path.parent() {
|
||||
@ -114,6 +123,7 @@ impl Dir {
|
||||
.and_then(|f| dir.0.read().assets.get(f.to_str().unwrap()).cloned())
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn get_metadata(&self, path: &Path) -> Option<Data> {
|
||||
let mut dir = self.clone();
|
||||
if let Some(parent) = path.parent() {
|
||||
@ -124,11 +134,13 @@ impl Dir {
|
||||
.and_then(|f| dir.0.read().metadata.get(f.to_str().unwrap()).cloned())
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub fn path(&self) -> PathBuf {
|
||||
self.0.read().path.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub struct DirStream {
|
||||
dir: Dir,
|
||||
index: usize,
|
||||
@ -176,6 +188,7 @@ impl Stream for DirStream {
|
||||
/// This is primarily intended for unit tests.
|
||||
#[derive(Default, Clone)]
|
||||
pub struct MemoryAssetReader {
|
||||
/// TODO
|
||||
pub root: Dir,
|
||||
}
|
||||
|
||||
@ -189,7 +202,9 @@ pub struct Data {
|
||||
/// Stores either an allocated vec of bytes or a static array of bytes.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Value {
|
||||
/// TODO
|
||||
Vec(Arc<Vec<u8>>),
|
||||
/// TODO
|
||||
Static(&'static [u8]),
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
#[cfg(all(feature = "file_watcher", target_arch = "wasm32"))]
|
||||
compile_error!(
|
||||
"The \"file_watcher\" feature for hot reloading does not work \
|
||||
@ -135,6 +137,7 @@ pub trait AsyncSeekForwardExt: AsyncSeekForward {
|
||||
|
||||
impl<R: AsyncSeekForward + ?Sized> AsyncSeekForwardExt for R {}
|
||||
|
||||
/// TODO
|
||||
#[derive(Debug)]
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
pub struct SeekForwardFuture<'a, S: Unpin + ?Sized> {
|
||||
@ -188,6 +191,7 @@ impl Reader for Box<dyn Reader + '_> {
|
||||
pub trait AssetReaderFuture:
|
||||
ConditionalSendFuture<Output = Result<Self::Value, AssetReaderError>>
|
||||
{
|
||||
/// TODO
|
||||
type Value;
|
||||
}
|
||||
|
||||
@ -326,8 +330,10 @@ impl<T: AssetReader> ErasedAssetReader for T {
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub type Writer = dyn AsyncWrite + Unpin + Send + Sync;
|
||||
|
||||
/// TODO
|
||||
pub type PathStream = dyn Stream<Item = PathBuf> + Unpin + Send;
|
||||
|
||||
/// Errors that occur while loading assets.
|
||||
@ -583,7 +589,12 @@ pub enum AssetSourceEvent {
|
||||
/// An asset at this path was removed.
|
||||
RemovedAsset(PathBuf),
|
||||
/// An asset at this path was renamed.
|
||||
RenamedAsset { old: PathBuf, new: PathBuf },
|
||||
RenamedAsset {
|
||||
/// TODO
|
||||
old: PathBuf,
|
||||
/// TODO
|
||||
new: PathBuf
|
||||
},
|
||||
/// Asset metadata at this path was added.
|
||||
AddedMeta(PathBuf),
|
||||
/// Asset metadata at this path was modified.
|
||||
@ -591,13 +602,23 @@ pub enum AssetSourceEvent {
|
||||
/// Asset metadata at this path was removed.
|
||||
RemovedMeta(PathBuf),
|
||||
/// Asset metadata at this path was renamed.
|
||||
RenamedMeta { old: PathBuf, new: PathBuf },
|
||||
RenamedMeta {
|
||||
/// TODO
|
||||
old: PathBuf,
|
||||
/// TODO
|
||||
new: PathBuf
|
||||
},
|
||||
/// A folder at the given path was added.
|
||||
AddedFolder(PathBuf),
|
||||
/// A folder at the given path was removed.
|
||||
RemovedFolder(PathBuf),
|
||||
/// A folder at the given path was renamed.
|
||||
RenamedFolder { old: PathBuf, new: PathBuf },
|
||||
RenamedFolder {
|
||||
/// TODO
|
||||
old: PathBuf,
|
||||
/// TODO
|
||||
new: PathBuf
|
||||
},
|
||||
/// Something of unknown type was removed. It is the job of the event handler to determine the type.
|
||||
/// This exists because notify-rs produces "untyped" rename events without destination paths for unwatched folders, so we can't determine the type of
|
||||
/// the rename.
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
use crate::{
|
||||
io::{AssetReader, AssetReaderError, AssetSourceId, PathStream, Reader},
|
||||
processor::{AssetProcessorData, ProcessStatus},
|
||||
|
@ -138,7 +138,6 @@
|
||||
//! If you want to save your assets back to disk, you should implement [`AssetSaver`](saver::AssetSaver) as well.
|
||||
//! This trait mirrors [`AssetLoader`] in structure, and works in tandem with [`AssetWriter`](io::AssetWriter), which mirrors [`AssetReader`](io::AssetReader).
|
||||
|
||||
#![expect(missing_docs, reason = "Not all docs are written yet, see #3492.")]
|
||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||
#![doc(
|
||||
html_logo_url = "https://bevy.org/assets/icon.png",
|
||||
@ -455,6 +454,7 @@ pub trait AsAssetId: Component {
|
||||
///
|
||||
/// Note that this trait is automatically implemented when deriving [`Asset`].
|
||||
pub trait VisitAssetDependencies {
|
||||
/// TODO
|
||||
fn visit_dependencies(&self, visit: &mut impl FnMut(UntypedAssetId));
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,9 @@ impl ErasedLoadedAsset {
|
||||
|
||||
/// A type erased container for an [`Asset`] value that is capable of inserting the [`Asset`] into a [`World`]'s [`Assets`] collection.
|
||||
pub trait AssetContainer: Downcast + Any + Send + Sync + 'static {
|
||||
/// TODO
|
||||
fn insert(self: Box<Self>, id: UntypedAssetId, world: &mut World);
|
||||
/// TODO
|
||||
fn asset_type_name(&self) -> &'static str;
|
||||
}
|
||||
|
||||
@ -291,11 +293,15 @@ impl<A: Asset> AssetContainer for A {
|
||||
/// [immediately]: crate::Immediate
|
||||
#[derive(Error, Debug)]
|
||||
pub enum LoadDirectError {
|
||||
/// TODO
|
||||
#[error("Requested to load an asset path ({0:?}) with a subasset, but this is unsupported. See issue #18291")]
|
||||
RequestedSubasset(AssetPath<'static>),
|
||||
/// TODO
|
||||
#[error("Failed to load dependency {dependency:?} {error}")]
|
||||
LoadError {
|
||||
/// TODO
|
||||
dependency: AssetPath<'static>,
|
||||
/// TODO
|
||||
error: AssetLoadError,
|
||||
},
|
||||
}
|
||||
@ -303,8 +309,10 @@ pub enum LoadDirectError {
|
||||
/// An error that occurs while deserializing [`AssetMeta`].
|
||||
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
||||
pub enum DeserializeMetaError {
|
||||
/// TODO
|
||||
#[error("Failed to deserialize asset meta: {0:?}")]
|
||||
DeserializeSettings(#[from] SpannedError),
|
||||
/// TODO
|
||||
#[error("Failed to deserialize minimal asset meta: {0:?}")]
|
||||
DeserializeMinimal(SpannedError),
|
||||
}
|
||||
@ -568,20 +576,27 @@ impl<'a> LoadContext<'a> {
|
||||
/// An error produced when calling [`LoadContext::read_asset_bytes`]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ReadAssetBytesError {
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
DeserializeMetaError(#[from] DeserializeMetaError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
AssetReaderError(#[from] AssetReaderError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingAssetSourceError(#[from] MissingAssetSourceError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingProcessedAssetReaderError(#[from] MissingProcessedAssetReaderError),
|
||||
/// Encountered an I/O error while loading an asset.
|
||||
#[error("Encountered an io error while loading asset at `{}`: {source}", path.display())]
|
||||
Io {
|
||||
/// TODO
|
||||
path: PathBuf,
|
||||
/// TODO
|
||||
source: std::io::Error,
|
||||
},
|
||||
/// TODO
|
||||
#[error("The LoadContext for this read_asset_bytes call requires hash metadata, but it was not provided. This is likely an internal implementation error.")]
|
||||
MissingAssetHash,
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
string::{String, ToString},
|
||||
@ -13,7 +15,10 @@ use ron::ser::PrettyConfig;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::error;
|
||||
|
||||
/// TODO
|
||||
pub const META_FORMAT_VERSION: &str = "1.0";
|
||||
|
||||
/// TODO
|
||||
pub type MetaTransform = Box<dyn Fn(&mut dyn AssetMetaDyn) + Send + Sync>;
|
||||
|
||||
/// Asset metadata that informs how an [`Asset`] should be handled by the asset system.
|
||||
@ -36,6 +41,7 @@ pub struct AssetMeta<L: AssetLoader, P: Process> {
|
||||
}
|
||||
|
||||
impl<L: AssetLoader, P: Process> AssetMeta<L, P> {
|
||||
/// TODO
|
||||
pub fn new(asset: AssetAction<L::Settings, P::Settings>) -> Self {
|
||||
Self {
|
||||
meta_format_version: META_FORMAT_VERSION.to_string(),
|
||||
@ -56,7 +62,9 @@ pub enum AssetAction<LoaderSettings, ProcessSettings> {
|
||||
/// Load the asset with the given loader and settings
|
||||
/// See [`AssetLoader`].
|
||||
Load {
|
||||
/// TODO
|
||||
loader: String,
|
||||
/// TODO
|
||||
settings: LoaderSettings,
|
||||
},
|
||||
/// Process the asset with the given processor and settings.
|
||||
@ -64,7 +72,9 @@ pub enum AssetAction<LoaderSettings, ProcessSettings> {
|
||||
///
|
||||
/// [`AssetProcessor`]: crate::processor::AssetProcessor
|
||||
Process {
|
||||
/// TODO
|
||||
processor: String,
|
||||
/// TODO
|
||||
settings: ProcessSettings,
|
||||
},
|
||||
/// Do nothing with the asset
|
||||
@ -89,7 +99,9 @@ pub struct ProcessedInfo {
|
||||
/// has changed.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct ProcessDependencyInfo {
|
||||
/// TODO
|
||||
pub full_hash: AssetHash,
|
||||
/// TODO
|
||||
pub path: AssetPath<'static>,
|
||||
}
|
||||
|
||||
@ -101,6 +113,7 @@ pub struct ProcessDependencyInfo {
|
||||
// using a type registry.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct AssetMetaMinimal {
|
||||
/// TODO
|
||||
pub asset: AssetActionMinimal,
|
||||
}
|
||||
|
||||
@ -108,8 +121,17 @@ pub struct AssetMetaMinimal {
|
||||
/// isn't necessary.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum AssetActionMinimal {
|
||||
Load { loader: String },
|
||||
Process { processor: String },
|
||||
/// TODO
|
||||
Load {
|
||||
/// TODO
|
||||
loader: String
|
||||
},
|
||||
/// TODO
|
||||
Process {
|
||||
/// TODO
|
||||
processor: String
|
||||
},
|
||||
/// TODO
|
||||
Ignore,
|
||||
}
|
||||
|
||||
@ -117,6 +139,7 @@ pub enum AssetActionMinimal {
|
||||
/// necessary.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ProcessedInfoMinimal {
|
||||
/// TODO
|
||||
pub processed_info: Option<ProcessedInfo>,
|
||||
}
|
||||
|
||||
@ -238,6 +261,7 @@ pub(crate) fn loader_settings_meta_transform<S: Settings>(
|
||||
Box::new(move |meta| meta_transform_settings(meta, &settings))
|
||||
}
|
||||
|
||||
/// TODO
|
||||
pub type AssetHash = [u8; 32];
|
||||
|
||||
/// NOTE: changing the hashing logic here is a _breaking change_ that requires a [`META_FORMAT_VERSION`] bump.
|
||||
|
@ -163,6 +163,7 @@ impl AssetProcessor {
|
||||
self.data.sources.get(id.into())
|
||||
}
|
||||
|
||||
/// TODO
|
||||
#[inline]
|
||||
pub fn sources(&self) -> &AssetSources {
|
||||
&self.data.sources
|
||||
@ -1171,16 +1172,22 @@ impl<T: Process> Process for InstrumentedAssetProcessor<T> {
|
||||
/// The (successful) result of processing an asset
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ProcessResult {
|
||||
/// TODO
|
||||
Processed(ProcessedInfo),
|
||||
/// TODO
|
||||
SkippedNotChanged,
|
||||
/// TODO
|
||||
Ignored,
|
||||
}
|
||||
|
||||
/// The final status of processing an asset
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
pub enum ProcessStatus {
|
||||
/// TODO
|
||||
Processed,
|
||||
/// TODO
|
||||
Failed,
|
||||
/// TODO
|
||||
NonExistent,
|
||||
}
|
||||
|
||||
@ -1467,10 +1474,13 @@ pub enum ProcessorState {
|
||||
/// An error that occurs when initializing the [`AssetProcessor`].
|
||||
#[derive(Error, Debug)]
|
||||
pub enum InitializeError {
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
FailedToReadSourcePaths(AssetReaderError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
FailedToReadDestinationPaths(AssetReaderError),
|
||||
/// TODO
|
||||
#[error("Failed to validate asset log: {0}")]
|
||||
ValidateLogError(#[from] ValidateLogError),
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ impl<
|
||||
S: AssetSaver<Asset = T::AssetOutput>,
|
||||
> LoadTransformAndSave<L, T, S>
|
||||
{
|
||||
/// TODO
|
||||
pub fn new(transformer: T, saver: S) -> Self {
|
||||
LoadTransformAndSave {
|
||||
transformer,
|
||||
@ -113,49 +114,70 @@ impl<
|
||||
/// An error that is encountered during [`Process::process`].
|
||||
#[derive(Error, Debug)]
|
||||
pub enum ProcessError {
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingAssetLoaderForExtension(#[from] MissingAssetLoaderForExtensionError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingAssetLoaderForTypeName(#[from] MissingAssetLoaderForTypeNameError),
|
||||
/// TODO
|
||||
#[error("The processor '{0}' does not exist")]
|
||||
#[from(ignore)]
|
||||
MissingProcessor(String),
|
||||
/// TODO
|
||||
#[error("Encountered an AssetReader error for '{path}': {err}")]
|
||||
#[from(ignore)]
|
||||
AssetReaderError {
|
||||
/// TODO
|
||||
path: AssetPath<'static>,
|
||||
/// TODO
|
||||
err: AssetReaderError,
|
||||
},
|
||||
/// TODO
|
||||
#[error("Encountered an AssetWriter error for '{path}': {err}")]
|
||||
#[from(ignore)]
|
||||
AssetWriterError {
|
||||
/// TODO
|
||||
path: AssetPath<'static>,
|
||||
/// TODO
|
||||
err: AssetWriterError,
|
||||
},
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingAssetWriterError(#[from] MissingAssetWriterError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingProcessedAssetReaderError(#[from] MissingProcessedAssetReaderError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingProcessedAssetWriterError(#[from] MissingProcessedAssetWriterError),
|
||||
/// TODO
|
||||
#[error("Failed to read asset metadata for {path}: {err}")]
|
||||
#[from(ignore)]
|
||||
ReadAssetMetaError {
|
||||
/// TODO
|
||||
path: AssetPath<'static>,
|
||||
/// TODO
|
||||
err: AssetReaderError,
|
||||
},
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
DeserializeMetaError(#[from] DeserializeMetaError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
AssetLoadError(#[from] AssetLoadError),
|
||||
/// TODO
|
||||
#[error("The wrong meta type was passed into a processor. This is probably an internal implementation error.")]
|
||||
WrongMetaType,
|
||||
/// TODO
|
||||
#[error("Encountered an error while saving the asset: {0}")]
|
||||
#[from(ignore)]
|
||||
AssetSaveError(Box<dyn core::error::Error + Send + Sync + 'static>),
|
||||
/// TODO
|
||||
#[error("Encountered an error while transforming the asset: {0}")]
|
||||
#[from(ignore)]
|
||||
AssetTransformError(Box<dyn core::error::Error + Send + Sync + 'static>),
|
||||
/// TODO
|
||||
#[error("Assets without extensions are not supported.")]
|
||||
ExtensionRequired,
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
use crate::{
|
||||
io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader,
|
||||
ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle,
|
||||
|
@ -2050,20 +2050,28 @@ pub enum WaitForAssetError {
|
||||
DependencyFailed(Arc<AssetLoadError>),
|
||||
}
|
||||
|
||||
/// TODO
|
||||
#[derive(Error, Debug)]
|
||||
pub enum WriteDefaultMetaError {
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingAssetLoader(#[from] MissingAssetLoaderForExtensionError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingAssetSource(#[from] MissingAssetSourceError),
|
||||
/// TODO
|
||||
#[error(transparent)]
|
||||
MissingAssetWriter(#[from] MissingAssetWriterError),
|
||||
/// TODO
|
||||
#[error("failed to write default asset meta file: {0}")]
|
||||
FailedToWriteMeta(#[from] AssetWriterError),
|
||||
/// TODO
|
||||
#[error("asset meta file already exists, so avoiding overwrite")]
|
||||
MetaAlreadyExists,
|
||||
/// TODO
|
||||
#[error("encountered an I/O error while reading the existing meta file: {0}")]
|
||||
IoErrorFromExistingMetaCheck(Arc<std::io::Error>),
|
||||
/// TODO
|
||||
#[error("encountered HTTP status {0} when reading the existing meta file")]
|
||||
HttpErrorFromExistingMetaCheck(u16),
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! TODO
|
||||
|
||||
use crate::{meta::Settings, Asset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle};
|
||||
use alloc::boxed::Box;
|
||||
use atomicow::CowArc;
|
||||
|
Loading…
Reference in New Issue
Block a user