Struct littlefs2::fs::Filesystem [−][src]
Implementations
impl<Storage: Storage> Filesystem<'_, Storage>
[src]
pub fn allocate() -> Allocation<Storage>
[src]
pub fn format(storage: &mut Storage) -> Result<()>
[src]
pub fn is_mountable(storage: &mut Storage) -> bool
[src]
pub unsafe fn borrow_storage_mut(&mut self) -> &mut Storage
[src]
pub fn mount_and_then<R>(
storage: &mut Storage,
f: impl FnOnce(&Filesystem<'_, Storage>) -> Result<R>
) -> Result<R>
[src]
storage: &mut Storage,
f: impl FnOnce(&Filesystem<'_, Storage>) -> Result<R>
) -> Result<R>
This API avoids the need for using Allocation
.
pub fn total_blocks(&self) -> usize
[src]
Total number of blocks in the filesystem
pub fn total_space(&self) -> usize
[src]
Total number of bytes in the filesystem
pub fn available_blocks(&self) -> Result<usize>
[src]
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.
pub fn available_space(&self) -> Result<usize>
[src]
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.
pub fn remove(&self, path: &Path) -> Result<()>
[src]
Remove a file or directory.
pub fn remove_dir(&self, path: &Path) -> Result<()>
[src]
Remove a file or directory.
pub fn remove_dir_all(&self, path: &Path) -> Result<()>
[src]
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> where
P: Fn(&DirEntry) -> bool,
[src]
&self,
path: &Path,
predicate: &P
) -> Result<usize> where
P: Fn(&DirEntry) -> bool,
pub fn rename(&self, from: &Path, to: &Path) -> Result<()>
[src]
Rename or move a file or directory.
pub fn metadata(&self, path: &Path) -> Result<Metadata>
[src]
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>
) -> Result<R>
[src]
&self,
path: &Path,
f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R>
) -> Result<R>
pub fn open_file_and_then<R>(
&self,
path: &Path,
f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R>
) -> Result<R>
[src]
&self,
path: &Path,
f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R>
) -> Result<R>
pub fn with_options() -> OpenOptions
[src]
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>
) -> Result<R>
[src]
&self,
o: impl FnOnce(&mut OpenOptions) -> &OpenOptions,
path: &Path,
f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R>
) -> Result<R>
pub fn attribute(
&self,
path: &Path,
id: u8
) -> Result<Option<Attribute<Storage>>>
[src]
&self,
path: &Path,
id: u8
) -> Result<Option<Attribute<Storage>>>
Read attribute.
pub fn remove_attribute(&self, path: &Path, id: u8) -> Result<()>
[src]
Remove attribute.
pub fn set_attribute(
&self,
path: &Path,
attribute: &Attribute<Storage>
) -> Result<()>
[src]
&self,
path: &Path,
attribute: &Attribute<Storage>
) -> Result<()>
Set attribute.
impl<'a, Storage: Storage> Filesystem<'a, Storage>
[src]
pub fn read_dir_and_then<R>(
&self,
path: &Path,
f: impl FnOnce(&mut ReadDir<'_, '_, Storage>) -> Result<R>
) -> Result<R>
[src]
&self,
path: &Path,
f: impl FnOnce(&mut ReadDir<'_, '_, Storage>) -> Result<R>
) -> Result<R>
pub unsafe fn read_dir<'b>(
&'b self,
alloc: &'b mut ReadDirAllocation,
path: &Path
) -> Result<ReadDir<'a, 'b, Storage>>
[src]
&'b self,
alloc: &'b mut ReadDirAllocation,
path: &Path
) -> Result<ReadDir<'a, 'b, Storage>>
Returns a pseudo-iterator over the entries within a directory.
This is unsafe since it can induce UB just like File::open.
impl<'a, Storage: Storage> Filesystem<'a, Storage>
[src]
pub fn mount(
alloc: &'a mut Allocation<Storage>,
storage: &'a mut Storage
) -> Result<Self>
[src]
alloc: &'a mut Allocation<Storage>,
storage: &'a mut Storage
) -> Result<Self>
pub fn into_inner(self) -> (&'a mut Allocation<Storage>, &'a mut Storage)
[src]
Deconstruct Filesystem
, intention is to allow access to
the underlying Flash peripheral in driver::Storage etc.
See also borrow_storage_mut
.
pub fn create_dir(&self, path: &Path) -> Result<()>
[src]
Creates a new, empty directory at the provided path.
pub fn create_dir_all(&self, path: &Path) -> Result<()>
[src]
Recursively create a directory and all of its parent components if they are missing.
pub fn read<N: ArrayLength<u8>>(&self, path: &Path) -> Result<Vec<u8, N>>
[src]
Read the entire contents of a file into a bytes vector.
pub fn write(&self, path: &Path, contents: &[u8]) -> Result<()>
[src]
Write a slice as the entire contents of a file.
This function will create a file if it does not exist, and will entirely replace its contents if it does.
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,