pub struct Storage<M>{ /* private fields */ }Expand description
A mounted storage partition.
Implementations§
Source§impl<M> Storage<M>
impl<M> Storage<M>
Sourcepub async fn mount(partition: M) -> Result<Self, StorageError>
pub async fn mount(partition: M) -> Result<Self, StorageError>
Mounts the filesystem.
Returns an error if the filesystem is not formatted.
Sourcepub async fn format(partition: &mut M) -> Result<(), StorageError>
pub async fn format(partition: &mut M) -> Result<(), StorageError>
Unconditionally formats the filesystem.
Sourcepub async fn format_and_mount(partition: M) -> Result<Self, StorageError>
pub async fn format_and_mount(partition: M) -> Result<Self, StorageError>
Unconditionally formats then mounts the filesystem.
Sourcepub fn free_bytes(&self) -> usize
pub fn free_bytes(&self) -> usize
Returns the number of free bytes in the filesystem.
Note: this function does not count deleted files as free space, so the result will
not match the value capacity() - used_bytes().
Sourcepub async fn used_bytes(&mut self) -> Result<usize, StorageError>
pub async fn used_bytes(&mut self) -> Result<usize, StorageError>
Returns the number of bytes used in the filesystem.
This function takes filesystem overhead into account, but does not count deleted files.
Sourcepub async fn delete(&mut self, path: &str) -> Result<(), StorageError>
pub async fn delete(&mut self, path: &str) -> Result<(), StorageError>
Deletes the file at path.
Sourcepub async fn store(
&mut self,
path: &str,
data: &[u8],
if_exists: OnCollision,
) -> Result<(), StorageError>
pub async fn store( &mut self, path: &str, data: &[u8], if_exists: OnCollision, ) -> Result<(), StorageError>
Creates a new file at path with the given data.
If a file already exists at path, the behaviour is determined by if_exists.
OnCollision::Overwritewill overwrite the existing file.OnCollision::Failwill return an error.
Sourcepub async fn exists(&mut self, path: &str) -> bool
pub async fn exists(&mut self, path: &str) -> bool
Convenience method for checking if a file exists. Ignores all errors.
Source§impl<P> Storage<Counters<P>>
impl<P> Storage<Counters<P>>
pub fn erase_count(&self) -> usize
pub fn read_count(&self) -> usize
pub fn write_count(&self) -> usize
Auto Trait Implementations§
impl<M> Freeze for Storage<M>where
M: Freeze,
impl<M> RefUnwindSafe for Storage<M>where
M: RefUnwindSafe,
impl<M> Send for Storage<M>where
M: Send,
impl<M> Sync for Storage<M>where
M: Sync,
impl<M> Unpin for Storage<M>where
M: Unpin,
impl<M> UnwindSafe for Storage<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more