pub trait FileOpener: Send + 'static {
// Required method
fn open(&mut self) -> Result<(&dyn FileReader, u64), Error>;
// Provided method
fn from_cache(&mut self) -> Option<Result<&[u8], Error>> { ... }
}Expand description
This trait represents anything that can open the file
You can convert anything that is AsRef<Path> to this trait and
it will just open a file at specified path.
But often you want some checks of permissions or visibility of the file
while opening it. You can’t do even stat() or open() in main loop
because even such a simple operation can potentially block for indefinite
period of time.
So file opener could be anything that validates a path, caches file descriptor, and in the result returns a file.
Required Methods§
Provided Methods§
Implementors§
impl FileOpener for PathOpener
Available on Unix only.