pub trait Dir {
type Read: Read;
type Write: Write;
// Required methods
fn open_file(&mut self, name: &str) -> Result<Self::Read, FSError>;
fn create_file(&mut self, name: &str) -> Result<Self::Write, FSError>;
fn append_file(&mut self, name: &str) -> Result<Self::Write, FSError>;
fn get_file_size(&mut self, name: &str) -> Result<u32, FSError>;
fn remove_file(&mut self, name: &str) -> Result<(), FSError>;
fn iter_dir<F>(&mut self, f: F) -> Result<(), FSError>
where F: FnMut(EntryKind, &[u8]);
}Required Associated Types§
Required Methods§
Sourcefn open_file(&mut self, name: &str) -> Result<Self::Read, FSError>
fn open_file(&mut self, name: &str) -> Result<Self::Read, FSError>
Open a file for reading.
The file path is given as a slice of path components. There are at least 4 components:
- the first one is the root directory (either “roms” or “data”),
- the second is the author ID,
- the third is the app ID,
- (optional) directory names if the file is nested,
- and the last is file name.
The runtime ensures that the path is relative and never goes up the tree.
The whole filesystem abstraction (this method and the ones below) is designed to work nicely with embedded_sdmmc and the stdlib filesystem.
Sourcefn create_file(&mut self, name: &str) -> Result<Self::Write, FSError>
fn create_file(&mut self, name: &str) -> Result<Self::Write, FSError>
Create a new file and open it for write.
If the file already exists, it will be overwritten.
Sourcefn append_file(&mut self, name: &str) -> Result<Self::Write, FSError>
fn append_file(&mut self, name: &str) -> Result<Self::Write, FSError>
Write data to the end of the file.
Sourcefn get_file_size(&mut self, name: &str) -> Result<u32, FSError>
fn get_file_size(&mut self, name: &str) -> Result<u32, FSError>
Get file size in bytes.
None should be returned if file not found.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.