Trait fyrox::asset::io::ResourceIo

source ·
pub trait ResourceIo: Send + Sync + 'static {
    // Required methods
    fn load_file<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, FileLoadError>> + Send + 'a>>;
    fn move_file<'a>(
        &'a self,
        source: &'a Path,
        dest: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<(), FileLoadError>> + Send + 'a>>;
    fn exists<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>;
    fn is_file<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>;
    fn is_dir<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'a>>;

    // Provided methods
    fn canonicalize_path<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileLoadError>> + Send + 'a>> { ... }
    fn read_directory<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>> + Send + 'a>> { ... }
    fn walk_directory<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>> + Send + 'a>> { ... }
    fn file_reader<'a>(
        &'a self,
        path: &'a Path
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn FileReader>, FileLoadError>> + Send + 'a>> { ... }
}
Expand description

Interface wrapping IO operations for doing this like loading files for resources

Required Methods§

source

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

Attempts to load the file at the provided path returning the entire byte contents of the file or an error

source

fn move_file<'a>( &'a self, source: &'a Path, dest: &'a Path ) -> Pin<Box<dyn Future<Output = Result<(), FileLoadError>> + Send + 'a>>

Attempts to move a file at the given source path to the given dest path.

source

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

Used to check whether a path exists

source

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

Used to check whether a path is a file

source

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

Used to check whether a path is a dir

Provided Methods§

source

fn canonicalize_path<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<PathBuf, FileLoadError>> + Send + 'a>>

Tries to convert the path to its canonical form (normalize it in other terms). This method should guarantee correct behaviour for relative paths. Symlinks aren’t mandatory to follow.

source

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

Provides an iterator over the paths present in the provided path, this should only provide paths immediately within the directory

Default implementation is no-op returning an empty iterator

source

fn walk_directory<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>> + Send + 'a>>

Provides an iterator over the paths present in the provided path directory this implementation should walk the directory paths

Default implementation is no-op returning an empty iterator

source

fn file_reader<'a>( &'a self, path: &'a Path ) -> Pin<Box<dyn Future<Output = Result<Box<dyn FileReader>, FileLoadError>> + Send + 'a>>

Attempts to open a file reader to the proivded path for reading its bytes

Default implementation loads the entire file contents from load_file then uses a cursor as the reader

Implementors§