Skip to main content

Volume

Struct Volume 

Source
pub struct Volume<D: BlockDevice> { /* private fields */ }
Expand description

A mounted volume. The filesystem type is detected from the boot sector, so callers use one API for FAT32 and exFAT cards.

Implementations§

Source§

impl<D: BlockDevice> Volume<D>

Source

pub fn mount(device: D) -> impl Future<Output = Result<Self, Error<D::Error>>>

Mounts the volume on device, detecting FAT32 or exFAT from the boot sector at block 0 or in the first partition of an MBR. Fails with Error::FilesystemNotEnabled if the card holds a filesystem whose feature is off.

The returned future holds device once, and the detection work borrows it. (An async fn would hold two copies of an argument, which for a card of a few kilobytes is the larger part of the future.)

Source

pub fn into_device(self) -> D

The device, when the volume is no longer wanted.

Source

pub fn open_root(&self) -> Directory

The root directory.

Source

pub async fn open_file(&mut self, path: &str) -> Result<File, Error<D::Error>>

Opens the file at path: names separated by /, matched ignoring ASCII case. A leading / is allowed.

Source

pub async fn open_dir( &mut self, path: &str, ) -> Result<Directory, Error<D::Error>>

Opens the directory at path, as for open_file.

Source

pub async fn next_entry( &mut self, dir: &mut Directory, ) -> Result<Option<DirEntry>, Error<D::Error>>

The next entry of dir, or None at the end. Entries come in directory order; . and .. are skipped.

Source

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

Reads from the file’s position into buffer and advances it; returns the bytes read, 0 at the end of the file.

Source

pub async fn seek( &mut self, file: &mut File, position: u64, ) -> Result<(), Error<D::Error>>

Moves the file’s position to position bytes from the start; past the end of the file is Error::InvalidPosition.

Auto Trait Implementations§

§

impl<D> Forget for Volume<D>

§

impl<D> Freeze for Volume<D>
where D: Freeze,

§

impl<D> Move for Volume<D>

§

impl<D> RefUnwindSafe for Volume<D>
where D: RefUnwindSafe,

§

impl<D> Send for Volume<D>
where D: Send,

§

impl<D> Sync for Volume<D>
where D: Sync,

§

impl<D> Unpin for Volume<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for Volume<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for Volume<D>
where D: 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.