Skip to main content

FileSystem

Struct FileSystem 

Source
pub struct FileSystem<D, const SIZE: usize, const N: usize>
where D: BlockDevice<SIZE>,
{ /* private fields */ }

Implementations§

Source§

impl<D, const SIZE: usize, const N: usize> FileSystem<D, SIZE, N>
where D: BlockDevice<SIZE>,

Source

pub fn new(io: D) -> Self

Source

pub fn into_inner(self) -> D

Source

pub fn set_time_provider(&mut self, time_provider: fn() -> Timestamp)

Sets the time provider for file and directory timestamps

Source

pub async fn mount(&mut self) -> ExFatResult<(), D, SIZE>

Calling this is optional as the file system will be automatically mounted upon first use if it is not already mounted Reads the boot sector using the block device and initializes the file system returning an instance of it

Source

pub async fn open( &mut self, path: &str, options: OpenOptions, ) -> ExFatResult<File, D, SIZE>

Source

pub async fn exists(&mut self, path: &str) -> ExFatResult<bool, D, SIZE>

Returns true if the file or directory exists

Symbolic link following is not supported

Source

pub async fn read_dir( &mut self, path: &str, ) -> ExFatResult<DirectoryIterator<SIZE>, D, SIZE>

Returns an iterator over the entries in a directory

Supports nested paths

Source

pub async fn remove_file(&mut self, path: &str) -> ExFatResult<(), D, SIZE>

Deletes a file

Returns an error if the file does not exist or something else failed

Source

pub async fn create_directory(&mut self, path: &str) -> ExFatResult<(), D, SIZE>

Creates a directory recursively

The dir path can be nested

Source

pub async fn copy( &mut self, from_path: &str, to_path: &str, ) -> ExFatResult<(), D, SIZE>

Copies a file from one file to another

If directories in the to_path do not exist they will be created File attributes will also be copied but timestamps will be new

Source

pub async fn rename( &mut self, from_path: &str, to_path: &str, ) -> ExFatResult<(), D, SIZE>

Rename a file or folder (also know as move)

The from_path is the old file or directory path (including all sub directories) The to_path is the new file or directory path (including all sub directories) If the file or directory changes parent directories then this is considered to be a file move, otherwise a rename If the to_path contains directories that don’t yet exist they will be created.

Source

pub async fn remove_dir(&mut self, path: &str) -> ExFatResult<(), D, SIZE>

Removes an empty directory

Will return an error if the directory does not exist or is not empty

Source

pub async fn write( &mut self, path: &str, contents: impl AsRef<[u8]>, ) -> ExFatResult<(), D, SIZE>

Writes the entire contents to a file.

The file will be overwritten if it already exists. This function will create any directories in the path that do not already exist. Relative paths are not supported.

Source

pub async fn unmount(self) -> D

unmounts the file system and returns the device back to the user. IMPORTANT: it is up to the caller to ensure that all open files have been closed. it is not necessary to unmount the file system for consistency for example if you need to reboot However, a reboot SHOULD close all open files beforehand

Trait Implementations§

Source§

impl<D, const SIZE: usize, const N: usize> Debug for FileSystem<D, SIZE, N>
where D: BlockDevice<SIZE> + Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D, const SIZE: usize, const N: usize> Freeze for FileSystem<D, SIZE, N>
where D: Freeze, Allocator<D, SIZE, N>: Freeze, Fat<D, SIZE, N>: Freeze, SlotCache<D, SIZE, N>: Freeze,

§

impl<D, const SIZE: usize, const N: usize> RefUnwindSafe for FileSystem<D, SIZE, N>
where D: RefUnwindSafe, Allocator<D, SIZE, N>: RefUnwindSafe, Fat<D, SIZE, N>: RefUnwindSafe, SlotCache<D, SIZE, N>: RefUnwindSafe,

§

impl<D, const SIZE: usize, const N: usize> Send for FileSystem<D, SIZE, N>
where D: Send, Allocator<D, SIZE, N>: Send, Fat<D, SIZE, N>: Send, SlotCache<D, SIZE, N>: Send,

§

impl<D, const SIZE: usize, const N: usize> Sync for FileSystem<D, SIZE, N>
where D: Sync, Allocator<D, SIZE, N>: Sync, Fat<D, SIZE, N>: Sync, SlotCache<D, SIZE, N>: Sync,

§

impl<D, const SIZE: usize, const N: usize> Unpin for FileSystem<D, SIZE, N>
where D: Unpin, Allocator<D, SIZE, N>: Unpin, Fat<D, SIZE, N>: Unpin, SlotCache<D, SIZE, N>: Unpin,

§

impl<D, const SIZE: usize, const N: usize> UnsafeUnpin for FileSystem<D, SIZE, N>
where D: UnsafeUnpin, Allocator<D, SIZE, N>: UnsafeUnpin, Fat<D, SIZE, N>: UnsafeUnpin, SlotCache<D, SIZE, N>: UnsafeUnpin,

§

impl<D, const SIZE: usize, const N: usize> UnwindSafe for FileSystem<D, SIZE, N>
where D: UnwindSafe, Allocator<D, SIZE, N>: UnwindSafe, Fat<D, SIZE, N>: UnwindSafe, SlotCache<D, SIZE, N>: 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.