Struct embedded_sdmmc::VolumeManager
source · pub struct VolumeManager<D, T, const MAX_DIRS: usize = 4, const MAX_FILES: usize = 4, const MAX_VOLUMES: usize = 1>{ /* private fields */ }
Expand description
A VolumeManager
wraps a block device and gives access to the FAT-formatted
volumes within it.
Implementations§
source§impl<D, T> VolumeManager<D, T, 4, 4>
impl<D, T> VolumeManager<D, T, 4, 4>
sourcepub fn new(block_device: D, time_source: T) -> VolumeManager<D, T, 4, 4, 1>
pub fn new(block_device: D, time_source: T) -> VolumeManager<D, T, 4, 4, 1>
Create a new Volume Manager using a generic BlockDevice
. From this
object we can open volumes (partitions) and with those we can open
files.
This creates a VolumeManager
with default values
MAX_DIRS = 4, MAX_FILES = 4, MAX_VOLUMES = 1. Call VolumeManager::new_with_limits(block_device, time_source)
if you need different limits.
source§impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
sourcepub fn new_with_limits(
block_device: D,
time_source: T,
id_offset: u32
) -> VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
pub fn new_with_limits( block_device: D, time_source: T, id_offset: u32 ) -> VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
Create a new Volume Manager using a generic BlockDevice
. From this
object we can open volumes (partitions) and with those we can open
files.
You can also give an offset for all the IDs this volume manager generates, which might help you find the IDs in your logs when debugging.
sourcepub fn open_volume(
&mut self,
volume_idx: VolumeIdx
) -> Result<Volume<'_, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>
pub fn open_volume( &mut self, volume_idx: VolumeIdx ) -> Result<Volume<'_, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>
Get a volume (or partition) based on entries in the Master Boot Record.
We do not support GUID Partition Table disks. Nor do we support any concept of drive letters - that is for a higher layer to handle.
sourcepub fn open_raw_volume(
&mut self,
volume_idx: VolumeIdx
) -> Result<RawVolume, Error<D::Error>>
pub fn open_raw_volume( &mut self, volume_idx: VolumeIdx ) -> Result<RawVolume, Error<D::Error>>
Get a volume (or partition) based on entries in the Master Boot Record.
We do not support GUID Partition Table disks. Nor do we support any concept of drive letters - that is for a higher layer to handle.
This function gives you a RawVolume
and you must close the volume by
calling VolumeManager::close_volume
.
sourcepub fn open_root_dir(
&mut self,
volume: RawVolume
) -> Result<RawDirectory, Error<D::Error>>
pub fn open_root_dir( &mut self, volume: RawVolume ) -> Result<RawDirectory, Error<D::Error>>
Open the volume’s root directory.
You can then read the directory entries with iterate_dir
, or you can
use open_file_in_dir
.
sourcepub fn open_dir<N>(
&mut self,
parent_dir: RawDirectory,
name: N
) -> Result<RawDirectory, Error<D::Error>>where
N: ToShortFileName,
pub fn open_dir<N>(
&mut self,
parent_dir: RawDirectory,
name: N
) -> Result<RawDirectory, Error<D::Error>>where
N: ToShortFileName,
Open a directory.
You can then read the directory entries with iterate_dir
and open_file_in_dir
.
Passing “.” as the name results in opening the parent_dir
a second time.
sourcepub fn close_dir(
&mut self,
directory: RawDirectory
) -> Result<(), Error<D::Error>>
pub fn close_dir( &mut self, directory: RawDirectory ) -> Result<(), Error<D::Error>>
Close a directory. You cannot perform operations on an open directory and so must close it if you want to do something with it.
sourcepub fn close_volume(&mut self, volume: RawVolume) -> Result<(), Error<D::Error>>
pub fn close_volume(&mut self, volume: RawVolume) -> Result<(), Error<D::Error>>
Close a volume
You can’t close it if there are any files or directories open on it.
sourcepub fn find_directory_entry<N>(
&mut self,
directory: RawDirectory,
name: N
) -> Result<DirEntry, Error<D::Error>>where
N: ToShortFileName,
pub fn find_directory_entry<N>(
&mut self,
directory: RawDirectory,
name: N
) -> Result<DirEntry, Error<D::Error>>where
N: ToShortFileName,
Look in a directory for a named file.
sourcepub fn iterate_dir<F>(
&mut self,
directory: RawDirectory,
func: F
) -> Result<(), Error<D::Error>>
pub fn iterate_dir<F>( &mut self, directory: RawDirectory, func: F ) -> Result<(), Error<D::Error>>
Call a callback function for each directory entry in a directory.
sourcepub fn open_file_in_dir<N>(
&mut self,
directory: RawDirectory,
name: N,
mode: Mode
) -> Result<RawFile, Error<D::Error>>where
N: ToShortFileName,
pub fn open_file_in_dir<N>(
&mut self,
directory: RawDirectory,
name: N,
mode: Mode
) -> Result<RawFile, Error<D::Error>>where
N: ToShortFileName,
Open a file with the given full path. A file can only be opened once.
sourcepub fn delete_file_in_dir<N>(
&mut self,
directory: RawDirectory,
name: N
) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
pub fn delete_file_in_dir<N>(
&mut self,
directory: RawDirectory,
name: N
) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
Delete a closed file with the given filename, if it exists.
sourcepub fn read(
&mut self,
file: RawFile,
buffer: &mut [u8]
) -> Result<usize, Error<D::Error>>
pub fn read( &mut self, file: RawFile, buffer: &mut [u8] ) -> Result<usize, Error<D::Error>>
Read from an open file.
sourcepub fn write(
&mut self,
file: RawFile,
buffer: &[u8]
) -> Result<(), Error<D::Error>>
pub fn write( &mut self, file: RawFile, buffer: &[u8] ) -> Result<(), Error<D::Error>>
Write to a open file.
sourcepub fn close_file(&mut self, file: RawFile) -> Result<(), Error<D::Error>>
pub fn close_file(&mut self, file: RawFile) -> Result<(), Error<D::Error>>
Close a file with the given full path.
sourcepub fn has_open_handles(&self) -> bool
pub fn has_open_handles(&self) -> bool
Check if any files or folders are open.
sourcepub fn file_eof(&self, file: RawFile) -> Result<bool, Error<D::Error>>
pub fn file_eof(&self, file: RawFile) -> Result<bool, Error<D::Error>>
Check if a file is at End Of File.
sourcepub fn file_seek_from_start(
&mut self,
file: RawFile,
offset: u32
) -> Result<(), Error<D::Error>>
pub fn file_seek_from_start( &mut self, file: RawFile, offset: u32 ) -> Result<(), Error<D::Error>>
Seek a file with an offset from the start of the file.
sourcepub fn file_seek_from_current(
&mut self,
file: RawFile,
offset: i32
) -> Result<(), Error<D::Error>>
pub fn file_seek_from_current( &mut self, file: RawFile, offset: i32 ) -> Result<(), Error<D::Error>>
Seek a file with an offset from the current position.
sourcepub fn file_seek_from_end(
&mut self,
file: RawFile,
offset: u32
) -> Result<(), Error<D::Error>>
pub fn file_seek_from_end( &mut self, file: RawFile, offset: u32 ) -> Result<(), Error<D::Error>>
Seek a file with an offset back from the end of the file.
sourcepub fn file_length(&self, file: RawFile) -> Result<u32, Error<D::Error>>
pub fn file_length(&self, file: RawFile) -> Result<u32, Error<D::Error>>
Get the length of a file
sourcepub fn file_offset(&self, file: RawFile) -> Result<u32, Error<D::Error>>
pub fn file_offset(&self, file: RawFile) -> Result<u32, Error<D::Error>>
Get the current offset of a file
sourcepub fn make_dir_in_dir<N>(
&mut self,
directory: RawDirectory,
name: N
) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
pub fn make_dir_in_dir<N>(
&mut self,
directory: RawDirectory,
name: N
) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
Create a directory in a given directory.