Trait bevy::asset::io::AssetReader

source ·
pub trait AssetReader: Send + Sync + 'static {
    // Required methods
    fn read<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncRead + Send + Sync + Unpin + 'a>, AssetReaderError>> + Send + 'a>>;
    fn read_meta<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncRead + Send + Sync + Unpin + 'a>, AssetReaderError>> + Send + 'a>>;
    fn read_directory<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = PathBuf> + Send + Unpin>, AssetReaderError>> + Send + 'a>>;
    fn is_directory<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<bool, AssetReaderError>> + Send + 'a>>;

    // Provided method
    fn read_meta_bytes<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AssetReaderError>> + Send + 'a>> { ... }
}
Expand description

Performs read operations on an asset storage. AssetReader exposes a “virtual filesystem” API, where asset bytes and asset metadata bytes are both stored and accessible for a given path.

Also see AssetWriter.

Required Methods§

source

fn read<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncRead + Send + Sync + Unpin + 'a>, AssetReaderError>> + Send + 'a>>

Returns a future to load the full file data at the provided path.

source

fn read_meta<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<Box<dyn AsyncRead + Send + Sync + Unpin + 'a>, AssetReaderError>> + Send + 'a>>

Returns a future to load the full file data at the provided path.

source

fn read_directory<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Stream<Item = PathBuf> + Send + Unpin>, AssetReaderError>> + Send + 'a>>

Returns an iterator of directory entry names at the provided path.

source

fn is_directory<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<bool, AssetReaderError>> + Send + 'a>>

Returns true if the provided path points to a directory.

Provided Methods§

source

fn read_meta_bytes<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, AssetReaderError>> + Send + 'a>>

Reads asset metadata bytes at the given path into a Vec<u8>. This is a convenience function that wraps AssetReader::read_meta by default.

Implementors§