pub struct Controller<D, T, const MAX_DIRS: usize = 4, const MAX_FILES: usize = 4>where
    D: BlockDevice,
    T: TimeSource,
    <D as BlockDevice>::Error: Debug,{ /* private fields */ }
Expand description

A VolumeManager wraps a block device and gives access to the volumes within it.

Implementations§

source§

impl<D, T> VolumeManager<D, T, 4, 4>where D: BlockDevice, T: TimeSource, <D as BlockDevice>::Error: Debug,

source

pub fn new(block_device: D, timesource: T) -> VolumeManager<D, T, 4, 4>

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. Call VolumeManager::new_with_limits(block_device, timesource) if you need different limits.

source§

impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize> VolumeManager<D, T, MAX_DIRS, MAX_FILES>where D: BlockDevice, T: TimeSource, <D as BlockDevice>::Error: Debug,

source

pub fn new_with_limits( block_device: D, timesource: T ) -> VolumeManager<D, T, MAX_DIRS, MAX_FILES>

Create a new Volume Manager using a generic BlockDevice. From this object we can open volumes (partitions) and with those we can open files.

source

pub fn device(&mut self) -> &mut D

Temporarily get access to the underlying block device.

source

pub fn get_volume( &mut self, volume_idx: VolumeIdx ) -> Result<Volume, 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.

source

pub fn open_root_dir( &mut self, volume: &Volume ) -> Result<Directory, Error<D::Error>>

Open a directory.

You can then read the directory entries with iterate_dir and open_file_in_dir.

TODO: Work out how to prevent damage occuring to the file system while this directory handle is open. In particular, stop this directory being unlinked.

source

pub fn open_dir( &mut self, volume: &Volume, parent_dir: &Directory, name: &str ) -> Result<Directory, Error<D::Error>>

Open a directory.

You can then read the directory entries with iterate_dir and open_file_in_dir.

TODO: Work out how to prevent damage occuring to the file system while this directory handle is open. In particular, stop this directory being unlinked.

source

pub fn close_dir(&mut self, volume: &Volume, dir: Directory)

Close a directory. You cannot perform operations on an open directory and so must close it if you want to do something with it.

source

pub fn find_directory_entry( &mut self, volume: &Volume, dir: &Directory, name: &str ) -> Result<DirEntry, Error<D::Error>>

Look in a directory for a named file.

source

pub fn iterate_dir<F>( &mut self, volume: &Volume, dir: &Directory, func: F ) -> Result<(), Error<D::Error>>where F: FnMut(&DirEntry),

Call a callback function for each directory entry in a directory.

source

pub fn open_dir_entry( &mut self, volume: &mut Volume, dir_entry: DirEntry, mode: Mode ) -> Result<File, Error<D::Error>>

Open a file from DirEntry. This is obtained by calling iterate_dir. A file can only be opened once.

source

pub fn open_file_in_dir( &mut self, volume: &mut Volume, dir: &Directory, name: &str, mode: Mode ) -> Result<File, Error<D::Error>>

Open a file with the given full path. A file can only be opened once.

source

pub fn delete_file_in_dir( &mut self, volume: &Volume, dir: &Directory, name: &str ) -> Result<(), Error<D::Error>>

Delete a closed file with the given full path, if exists.

source

pub fn read( &mut self, volume: &Volume, file: &mut File, buffer: &mut [u8] ) -> Result<usize, Error<D::Error>>

Read from an open file.

source

pub fn write( &mut self, volume: &mut Volume, file: &mut File, buffer: &[u8] ) -> Result<usize, Error<D::Error>>

Write to a open file.

source

pub fn close_file( &mut self, volume: &Volume, file: File ) -> Result<(), Error<D::Error>>

Close a file with the given full path.

source

pub fn has_open_handles(&self) -> bool

Check if any files or folders are open.

source

pub fn free(self) -> (D, T)

Consume self and return BlockDevice and TimeSource

Auto Trait Implementations§

§

impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize> RefUnwindSafe for VolumeManager<D, T, MAX_DIRS, MAX_FILES>where D: RefUnwindSafe, T: RefUnwindSafe,

§

impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize> Send for VolumeManager<D, T, MAX_DIRS, MAX_FILES>where D: Send, T: Send,

§

impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize> Sync for VolumeManager<D, T, MAX_DIRS, MAX_FILES>where D: Sync, T: Sync,

§

impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize> Unpin for VolumeManager<D, T, MAX_DIRS, MAX_FILES>where D: Unpin, T: Unpin,

§

impl<D, T, const MAX_DIRS: usize, const MAX_FILES: usize> UnwindSafe for VolumeManager<D, T, MAX_DIRS, MAX_FILES>where D: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.