Skip to main content

Directory

Struct Directory 

Source
pub struct Directory<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize>
where D: BlockDevice, T: TimeSource,
{ /* private fields */ }
Expand description

A handle for an open directory on disk, which closes on drop.

In contrast to a RawDirectory, a Directory holds a mutable reference to its parent VolumeManager, which restricts which operations you can perform.

If you drop a value of this type, it closes the directory automatically, but any error that may occur will be ignored. To handle potential errors, use the Directory::close method.

Implementations§

Source§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
where D: BlockDevice, T: TimeSource,

Source

pub fn new( raw_directory: RawDirectory, volume_mgr: &'a VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, ) -> Self

Create a new Directory from a RawDirectory

Source

pub fn open_dir<N>(&self, name: N) -> Result<Self, Error<D::Error>>
where N: ToShortFileName,

Open a directory.

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

See VolumeManager::open_dir for details, except the directory given is this directory.

Source

pub fn change_dir<N>(&mut self, name: N) -> Result<(), Error<D::Error>>
where N: ToShortFileName,

Change to a directory, mutating this object.

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

Source

pub fn find_directory_entry<N>( &self, name: N, ) -> Result<DirEntry, Error<D::Error>>
where N: ToShortFileName,

Read the directory entry with the given filename from this directory, if it exists.

See VolumeManager::find_directory_entry for details, except the directory given is this directory.

Source

pub fn directory_entry_exists<N: ToShortFileName>(&self, name: N) -> bool

Check whether a directory entry exists.

Source

pub fn iterate_dir<F>(&self, func: F) -> Result<(), Error<D::Error>>
where F: FnMut(&DirEntry) -> ControlFlow<()>,

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

Long File Names will be ignored.

See VolumeManager::iterate_dir for details, except the directory given is this directory.

Source

pub fn iterate_dir_lfn<F>( &self, lfn_buffer: &mut LfnBuffer<'_>, func: F, ) -> Result<(), Error<D::Error>>
where F: FnMut(&DirEntry, Option<&str>) -> ControlFlow<()>,

Call a callback function for each directory entry in a directory, and process Long File Names.

See VolumeManager::iterate_dir_lfn for details, except the directory given is this directory.

Source

pub fn open_file_in_dir<N>( &self, name: N, mode: Mode, ) -> Result<File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>
where N: ToShortFileName,

Open a file.

See VolumeManager::open_file_in_dir for details, except the directory given is this directory.

Source

pub fn open_long_name_file_in_dir( &self, name: &str, mode: Mode, ) -> Result<File<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>

Open a file.

See VolumeManager::open_long_name_file_in_dir for details, except the directory given is this directory.

Source

pub fn delete_entry_in_dir<N>(&self, name: N) -> Result<(), Error<D::Error>>
where N: ToShortFileName,

Delete a file/directory.

See VolumeManager::delete_entry_in_dir for details, except the directory given is this directory.

Source

pub fn make_dir_in_dir<N>(&self, name: N) -> Result<(), Error<D::Error>>
where N: ToShortFileName,

Create a new empty directory.

See VolumeManager::make_dir_in_dir for details, except the directory given is this directory.

Source

pub fn to_raw_directory(self) -> RawDirectory

Convert back to a raw directory

Source

pub fn close(self) -> Result<(), Error<D::Error>>

Consume the Directory handle and close it. The behavior of this is similar to using core::mem::drop or letting the Directory go out of scope, except this lets the user handle any errors that may occur in the process, whereas when using drop, any errors will be discarded silently.

Trait Implementations§

Source§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Debug for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
where D: BlockDevice, T: TimeSource,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Drop for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
where D: BlockDevice, T: TimeSource,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> !RefUnwindSafe for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>

§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> !Send for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>

§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> !Sync for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>

§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> !UnwindSafe for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>

§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Freeze for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>

§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Unpin for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>

§

impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> UnsafeUnpin for Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>

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.