embedded_sdmmc

Struct Controller

Source
pub struct Controller<D, T>
where D: BlockDevice, T: TimeSource, <D as BlockDevice>::Error: Debug,
{ /* private fields */ }
Expand description

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

Implementations§

Source§

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

Source

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

Create a new Disk Controller using a generic BlockDevice. From this controller 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 in a random order using get_directory_entry.

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 in a random order using get_directory_entry.

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_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 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.

Auto Trait Implementations§

§

impl<D, T> Freeze for Controller<D, T>
where D: Freeze, T: Freeze,

§

impl<D, T> RefUnwindSafe for Controller<D, T>

§

impl<D, T> Send for Controller<D, T>
where D: Send, T: Send,

§

impl<D, T> Sync for Controller<D, T>
where D: Sync, T: Sync,

§

impl<D, T> Unpin for Controller<D, T>
where D: Unpin, T: Unpin,

§

impl<D, T> UnwindSafe for Controller<D, T>
where D: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.