Trait bevy_asset::AssetIo
source · pub trait AssetIo: Downcast + Send + Sync + 'static {
fn load_path<'a>(
&'a self,
path: &'a Path
) -> BoxedFuture<'a, Result<Vec<u8>, AssetIoError>>;
fn read_directory(
&self,
path: &Path
) -> Result<Box<dyn Iterator<Item = PathBuf>>, AssetIoError>;
fn get_metadata(&self, path: &Path) -> Result<Metadata, AssetIoError>;
fn watch_path_for_changes(&self, path: &Path) -> Result<(), AssetIoError>;
fn watch_for_changes(&self) -> Result<(), AssetIoError>;
fn is_dir(&self, path: &Path) -> bool { ... }
fn is_file(&self, path: &Path) -> bool { ... }
}
Expand description
A storage provider for an AssetServer
.
An asset I/O is the backend actually providing data for the asset loaders managed by the asset
server. An average user will probably be just fine with the default FileAssetIo
, but you
can easily use your own custom I/O to, for example, load assets from cloud storage or create a
seamless VFS layout using custom containers.
See the custom_asset_io
example in the repository for more details.
Required Methods§
sourcefn load_path<'a>(
&'a self,
path: &'a Path
) -> BoxedFuture<'a, Result<Vec<u8>, AssetIoError>>
fn load_path<'a>(
&'a self,
path: &'a Path
) -> BoxedFuture<'a, Result<Vec<u8>, AssetIoError>>
Returns a future to load the full file data at the provided path.
sourcefn read_directory(
&self,
path: &Path
) -> Result<Box<dyn Iterator<Item = PathBuf>>, AssetIoError>
fn read_directory(
&self,
path: &Path
) -> Result<Box<dyn Iterator<Item = PathBuf>>, AssetIoError>
Returns an iterator of directory entry names at the provided path.
sourcefn get_metadata(&self, path: &Path) -> Result<Metadata, AssetIoError>
fn get_metadata(&self, path: &Path) -> Result<Metadata, AssetIoError>
Returns metadata about the filesystem entry at the provided path.
sourcefn watch_path_for_changes(&self, path: &Path) -> Result<(), AssetIoError>
fn watch_path_for_changes(&self, path: &Path) -> Result<(), AssetIoError>
Tells the asset I/O to watch for changes recursively at the provided path.
sourcefn watch_for_changes(&self) -> Result<(), AssetIoError>
fn watch_for_changes(&self) -> Result<(), AssetIoError>
Enables change tracking in this asset I/O.
Provided Methods§
Implementations§
source§impl dyn AssetIo
impl dyn AssetIo
sourcepub fn is<__T: AssetIo>(&self) -> bool
pub fn is<__T: AssetIo>(&self) -> bool
Returns true if the trait object wraps an object of type __T
.
sourcepub fn downcast<__T: AssetIo>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
pub fn downcast<__T: AssetIo>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn’t.
sourcepub fn downcast_rc<__T: AssetIo>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
pub fn downcast_rc<__T: AssetIo>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
Returns an Rc
-ed object from an Rc
-ed trait object if the underlying object is of
type __T
. Returns the original Rc
-ed trait if it isn’t.
sourcepub fn downcast_ref<__T: AssetIo>(&self) -> Option<&__T>
pub fn downcast_ref<__T: AssetIo>(&self) -> Option<&__T>
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn’t.
sourcepub fn downcast_mut<__T: AssetIo>(&mut self) -> Option<&mut __T>
pub fn downcast_mut<__T: AssetIo>(&mut self) -> Option<&mut __T>
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn’t.