Struct trussed::types::Filesystem
source · [−]pub struct Filesystem<'a, Storage> where
Storage: Storage, { /* private fields */ }
Implementations
sourceimpl<'_, Storage> Filesystem<'_, Storage> where
Storage: Storage,
impl<'_, Storage> Filesystem<'_, Storage> where
Storage: Storage,
pub fn allocate() -> Allocation<Storage>
pub fn format(storage: &mut Storage) -> Result<(), Error>
pub fn is_mountable(storage: &mut Storage) -> bool
pub unsafe fn borrow_storage_mut(&mut self) -> &mut Storage
sourcepub fn mount_and_then<R>(
storage: &mut Storage,
f: impl FnOnce(&Filesystem<'_, Storage>) -> Result<R, Error>
) -> Result<R, Error>
pub fn mount_and_then<R>(
storage: &mut Storage,
f: impl FnOnce(&Filesystem<'_, Storage>) -> Result<R, Error>
) -> Result<R, Error>
This API avoids the need for using Allocation
.
sourcepub fn total_blocks(&self) -> usize
pub fn total_blocks(&self) -> usize
Total number of blocks in the filesystem
sourcepub fn total_space(&self) -> usize
pub fn total_space(&self) -> usize
Total number of bytes in the filesystem
sourcepub fn available_blocks(&self) -> Result<usize, Error>
pub fn available_blocks(&self) -> Result<usize, Error>
Available number of unused blocks in the filesystem
Upstream littlefs documentation notes (on its “current size” function): “Result is best effort. If files share COW structures, the returned size may be larger than the filesystem actually is.”
So it would seem that there are at least the number of blocks returned by this method available, at any given time.
sourcepub fn available_space(&self) -> Result<usize, Error>
pub fn available_space(&self) -> Result<usize, Error>
Available number of unused bytes in the filesystem
This is a lower bound, more may be available. First, more blocks may be available as
explained in available_blocks
.
Second, files may be inlined.
sourcepub fn remove_dir_all(&self, path: &Path) -> Result<(), Error>
pub fn remove_dir_all(&self, path: &Path) -> Result<(), Error>
TODO: This method fails if some println!
calls are removed.
Whyy?
pub fn remove_dir_all_where<P>(
&self,
path: &Path,
predicate: &P
) -> Result<usize, Error> where
P: Fn(&DirEntry) -> bool,
sourcepub fn rename(&self, from: &Path, to: &Path) -> Result<(), Error>
pub fn rename(&self, from: &Path, to: &Path) -> Result<(), Error>
Rename or move a file or directory.
sourcepub fn metadata(&self, path: &Path) -> Result<Metadata, Error>
pub fn metadata(&self, path: &Path) -> Result<Metadata, Error>
Given a path, query the filesystem to get information about a file or directory.
To read user attributes, use
Filesystem::attribute
pub fn create_file_and_then<R>(
&self,
path: &Path,
f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R, Error>
) -> Result<R, Error>
pub fn open_file_and_then<R>(
&self,
path: &Path,
f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R, Error>
) -> Result<R, Error>
pub fn with_options() -> OpenOptions
pub fn open_file_with_options_and_then<R>(
&self,
o: impl FnOnce(&mut OpenOptions) -> &OpenOptions,
path: &Path,
f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R, Error>
) -> Result<R, Error>
sourceimpl<'a, Storage> Filesystem<'a, Storage> where
Storage: Storage,
impl<'a, Storage> Filesystem<'a, Storage> where
Storage: Storage,
sourceimpl<'a, Storage> Filesystem<'a, Storage> where
Storage: Storage,
impl<'a, Storage> Filesystem<'a, Storage> where
Storage: Storage,
pub fn mount(
alloc: &'a mut Allocation<Storage>,
storage: &'a mut Storage
) -> Result<Filesystem<'a, Storage>, Error>
sourcepub fn into_inner(self) -> (&'a mut Allocation<Storage>, &'a mut Storage)
pub fn into_inner(self) -> (&'a mut Allocation<Storage>, &'a mut Storage)
Deconstruct Filesystem
, intention is to allow access to
the underlying Flash peripheral in driver::Storage etc.
See also borrow_storage_mut
.
sourcepub fn create_dir(&self, path: &Path) -> Result<(), Error>
pub fn create_dir(&self, path: &Path) -> Result<(), Error>
Creates a new, empty directory at the provided path.
sourcepub fn create_dir_all(&self, path: &Path) -> Result<(), Error>
pub fn create_dir_all(&self, path: &Path) -> Result<(), Error>
Recursively create a directory and all of its parent components if they are missing.
Auto Trait Implementations
impl<'a, Storage> !RefUnwindSafe for Filesystem<'a, Storage>
impl<'a, Storage> !Send for Filesystem<'a, Storage>
impl<'a, Storage> !Sync for Filesystem<'a, Storage>
impl<'a, Storage> Unpin for Filesystem<'a, Storage>
impl<'a, Storage> !UnwindSafe for Filesystem<'a, Storage>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more