diff --git a/crates/bevy_asset/src/io/embedded/mod.rs b/crates/bevy_asset/src/io/embedded/mod.rs index f6c44397fc16f..d09d41062e367 100644 --- a/crates/bevy_asset/src/io/embedded/mod.rs +++ b/crates/bevy_asset/src/io/embedded/mod.rs @@ -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; } impl GetAssetServer for App { diff --git a/crates/bevy_asset/src/io/file/mod.rs b/crates/bevy_asset/src/io/file/mod.rs index 96c43072e8f47..8f9820950f6e5 100644 --- a/crates/bevy_asset/src/io/file/mod.rs +++ b/crates/bevy_asset/src/io/file/mod.rs @@ -1,3 +1,5 @@ +//! TODO + #[cfg(feature = "file_watcher")] mod file_watcher; diff --git a/crates/bevy_asset/src/io/gated.rs b/crates/bevy_asset/src/io/gated.rs index fa4f0f0d3fd30..3cacd2aca7662 100644 --- a/crates/bevy_asset/src/io/gated.rs +++ b/crates/bevy_asset/src/io/gated.rs @@ -1,3 +1,5 @@ +//! TODO +//! use crate::io::{AssetReader, AssetReaderError, PathStream, Reader}; use alloc::{boxed::Box, sync::Arc}; use bevy_platform::collections::HashMap; diff --git a/crates/bevy_asset/src/io/memory.rs b/crates/bevy_asset/src/io/memory.rs index 4c56057ff9e3c..1894de2f73928 100644 --- a/crates/bevy_asset/src/io/memory.rs +++ b/crates/bevy_asset/src/io/memory.rs @@ -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) { 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) { 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 { 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 { 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 { 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>), + /// TODO Static(&'static [u8]), } diff --git a/crates/bevy_asset/src/io/mod.rs b/crates/bevy_asset/src/io/mod.rs index aa7256bbd927b..be778143541d1 100644 --- a/crates/bevy_asset/src/io/mod.rs +++ b/crates/bevy_asset/src/io/mod.rs @@ -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 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 { pub trait AssetReaderFuture: ConditionalSendFuture> { + /// TODO type Value; } @@ -326,8 +330,10 @@ impl ErasedAssetReader for T { } } +/// TODO pub type Writer = dyn AsyncWrite + Unpin + Send + Sync; +/// TODO pub type PathStream = dyn Stream + 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. diff --git a/crates/bevy_asset/src/io/processor_gated.rs b/crates/bevy_asset/src/io/processor_gated.rs index da439f56f5e18..21abd7e1e71b8 100644 --- a/crates/bevy_asset/src/io/processor_gated.rs +++ b/crates/bevy_asset/src/io/processor_gated.rs @@ -1,3 +1,5 @@ +//! TODO + use crate::{ io::{AssetReader, AssetReaderError, AssetSourceId, PathStream, Reader}, processor::{AssetProcessorData, ProcessStatus}, diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 4b29beae799b5..6c4565f269a1b 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -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)); } diff --git a/crates/bevy_asset/src/loader.rs b/crates/bevy_asset/src/loader.rs index 24405f0657d5e..dab646f76f325 100644 --- a/crates/bevy_asset/src/loader.rs +++ b/crates/bevy_asset/src/loader.rs @@ -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, id: UntypedAssetId, world: &mut World); + /// TODO fn asset_type_name(&self) -> &'static str; } @@ -291,11 +293,15 @@ impl 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, } diff --git a/crates/bevy_asset/src/meta.rs b/crates/bevy_asset/src/meta.rs index 0e972261198cc..ea03a6417b725 100644 --- a/crates/bevy_asset/src/meta.rs +++ b/crates/bevy_asset/src/meta.rs @@ -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; /// Asset metadata that informs how an [`Asset`] should be handled by the asset system. @@ -36,6 +41,7 @@ pub struct AssetMeta { } impl AssetMeta { + /// TODO pub fn new(asset: AssetAction) -> Self { Self { meta_format_version: META_FORMAT_VERSION.to_string(), @@ -56,7 +62,9 @@ pub enum AssetAction { /// 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 { /// /// [`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, } @@ -238,6 +261,7 @@ pub(crate) fn loader_settings_meta_transform( 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. diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index a239d66a9b59a..dcf510ee5fd16 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -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 Process for InstrumentedAssetProcessor { /// 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), } diff --git a/crates/bevy_asset/src/processor/process.rs b/crates/bevy_asset/src/processor/process.rs index b37265d0fb660..525ded8a638ae 100644 --- a/crates/bevy_asset/src/processor/process.rs +++ b/crates/bevy_asset/src/processor/process.rs @@ -101,6 +101,7 @@ impl< S: AssetSaver, > LoadTransformAndSave { + /// 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), + /// TODO #[error("Encountered an error while transforming the asset: {0}")] #[from(ignore)] AssetTransformError(Box), + /// TODO #[error("Assets without extensions are not supported.")] ExtensionRequired, } diff --git a/crates/bevy_asset/src/saver.rs b/crates/bevy_asset/src/saver.rs index c8b96012eea72..e3a43a94f5494 100644 --- a/crates/bevy_asset/src/saver.rs +++ b/crates/bevy_asset/src/saver.rs @@ -1,3 +1,5 @@ +//! TODO + use crate::{ io::Writer, meta::Settings, transformer::TransformedAsset, Asset, AssetLoader, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle, diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index e120888616692..68123417ff199 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -2031,20 +2031,28 @@ pub enum WaitForAssetError { DependencyFailed(Arc), } +/// 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), + /// TODO #[error("encountered HTTP status {0} when reading the existing meta file")] HttpErrorFromExistingMetaCheck(u16), } diff --git a/crates/bevy_asset/src/transformer.rs b/crates/bevy_asset/src/transformer.rs index 802e3aeaa7eff..78cd4aeaba5c0 100644 --- a/crates/bevy_asset/src/transformer.rs +++ b/crates/bevy_asset/src/transformer.rs @@ -1,3 +1,5 @@ +//! TODO + use crate::{meta::Settings, Asset, ErasedLoadedAsset, Handle, LabeledAsset, UntypedHandle}; use alloc::boxed::Box; use atomicow::CowArc;