pub trait AssetIo: 'static + Downcast + Send + Sync {
fn load_path<'a>(
&'a self,
path: &'a Path
) -> Pin<Box<dyn Future<Output = Result<Vec<u8, Global>, AssetIoError>> + Send + 'a, Global>>;
fn read_directory(
&self,
path: &Path
) -> Result<Box<dyn Iterator<Item = PathBuf> + 'static, Global>, 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§
fn load_path<'a>(
&'a self,
path: &'a Path
) -> Pin<Box<dyn Future<Output = Result<Vec<u8, Global>, AssetIoError>> + Send + 'a, Global>>
fn load_path<'a>(
&'a self,
path: &'a Path
) -> Pin<Box<dyn Future<Output = Result<Vec<u8, Global>, AssetIoError>> + Send + 'a, Global>>
Returns a future to load the full file data at the provided path.
fn read_directory(
&self,
path: &Path
) -> Result<Box<dyn Iterator<Item = PathBuf> + 'static, Global>, AssetIoError>
fn read_directory(
&self,
path: &Path
) -> Result<Box<dyn Iterator<Item = PathBuf> + 'static, Global>, AssetIoError>
Returns an iterator of directory entry names at the provided path.
fn 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.
fn 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.
fn watch_for_changes(&self) -> Result<(), AssetIoError>
fn watch_for_changes(&self) -> Result<(), AssetIoError>
Enables change tracking in this asset I/O.
Provided Methods§
Implementations§
§impl dyn AssetIo + 'static
impl dyn AssetIo + 'static
pub fn is<__T>(&self) -> boolwhere
__T: AssetIo,
pub fn is<__T>(&self) -> boolwhere
__T: AssetIo,
Returns true if the trait object wraps an object of type __T.
pub fn downcast<__T>(
self: Box<dyn AssetIo + 'static, Global>
) -> Result<Box<__T, Global>, Box<dyn AssetIo + 'static, Global>>where
__T: AssetIo,
pub fn downcast<__T>(
self: Box<dyn AssetIo + 'static, Global>
) -> Result<Box<__T, Global>, Box<dyn AssetIo + 'static, Global>>where
__T: AssetIo,
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.
pub fn downcast_rc<__T>(
self: Rc<dyn AssetIo + 'static>
) -> Result<Rc<__T>, Rc<dyn AssetIo + 'static>>where
__T: AssetIo,
pub fn downcast_rc<__T>(
self: Rc<dyn AssetIo + 'static>
) -> Result<Rc<__T>, Rc<dyn AssetIo + 'static>>where
__T: AssetIo,
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.
pub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: AssetIo,
pub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: AssetIo,
Returns a reference to the object within the trait object if it is of type __T, or
None if it isn’t.
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: AssetIo,
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: AssetIo,
Returns a mutable reference to the object within the trait object if it is of type
__T, or None if it isn’t.