Struct littlefs2::fs::Filesystem[][src]

pub struct Filesystem<'a, Storage: Storage> { /* fields omitted */ }

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]

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]

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]

pub fn open_file_and_then<R>(
    &self,
    path: &Path,
    f: impl FnOnce(&File<'_, '_, Storage>) -> Result<R>
) -> Result<R>
[src]

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]

pub fn attribute(
    &self,
    path: &Path,
    id: u8
) -> Result<Option<Attribute<Storage>>>
[src]

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]

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]

pub unsafe fn read_dir<'b>(
    &'b self,
    alloc: &'b mut ReadDirAllocation,
    path: &Path
) -> Result<ReadDir<'a, 'b, Storage>>
[src]

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.