Trait fyrox_resource::io::ResourceIo
source · pub trait ResourceIo: Send + Sync + 'static {
// Required methods
fn load_file<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Vec<u8>, FileLoadError>>;
fn move_file<'a>(
&'a self,
source: &'a Path,
dest: &'a Path
) -> ResourceIoFuture<'a, Result<(), FileLoadError>>;
fn exists<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>;
fn is_file<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>;
fn is_dir<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>;
// Provided methods
fn canonicalize_path<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<PathBuf, FileLoadError>> { ... }
fn read_directory<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>> { ... }
fn walk_directory<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>> { ... }
fn file_reader<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Box<dyn FileReader>, FileLoadError>> { ... }
}
Expand description
Interface wrapping IO operations for doing this like loading files for resources
Required Methods§
sourcefn load_file<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Vec<u8>, FileLoadError>>
fn load_file<'a>( &'a self, path: &'a Path ) -> ResourceIoFuture<'a, Result<Vec<u8>, FileLoadError>>
Attempts to load the file at the provided path returning the entire byte contents of the file or an error
sourcefn move_file<'a>(
&'a self,
source: &'a Path,
dest: &'a Path
) -> ResourceIoFuture<'a, Result<(), FileLoadError>>
fn move_file<'a>( &'a self, source: &'a Path, dest: &'a Path ) -> ResourceIoFuture<'a, Result<(), FileLoadError>>
Attempts to move a file at the given source
path to the given dest
path.
sourcefn exists<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>
fn exists<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>
Used to check whether a path exists
sourcefn is_file<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>
fn is_file<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>
Used to check whether a path is a file
sourcefn is_dir<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>
fn is_dir<'a>(&'a self, path: &'a Path) -> ResourceIoFuture<'a, bool>
Used to check whether a path is a dir
Provided Methods§
sourcefn canonicalize_path<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<PathBuf, FileLoadError>>
fn canonicalize_path<'a>( &'a self, path: &'a Path ) -> ResourceIoFuture<'a, Result<PathBuf, FileLoadError>>
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.
sourcefn read_directory<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>>
fn read_directory<'a>( &'a self, path: &'a Path ) -> ResourceIoFuture<'a, Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>>
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
sourcefn walk_directory<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>>
fn walk_directory<'a>( &'a self, path: &'a Path ) -> ResourceIoFuture<'a, Result<Box<dyn Iterator<Item = PathBuf> + Send>, FileLoadError>>
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
sourcefn file_reader<'a>(
&'a self,
path: &'a Path
) -> ResourceIoFuture<'a, Result<Box<dyn FileReader>, FileLoadError>>
fn file_reader<'a>( &'a self, path: &'a Path ) -> ResourceIoFuture<'a, Result<Box<dyn FileReader>, FileLoadError>>
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