Skip to main content

FilesystemMut

Struct FilesystemMut 

Source
pub struct FilesystemMut<D: BlockDevice + 'static> { /* private fields */ }
Expand description

Mutable mounted filesystem shell backed by a real block device.

The mounted view owns the device and keeps a read-only parser view pointed at that same device through a small block cache. Mounted mutations commit through the block-device/cache layer only. Unsupported native transaction shapes return Error::Unsupported instead of falling back to a hidden capacity-sized image allocation.

Implementations§

§

impl<D: BlockDevice + 'static> FilesystemMut<D>

pub fn refresh(&mut self) -> Result<()>

Reparses visible filesystem state from the owned block device. Write methods call this after durable commits so subsequent reads observe exactly what a remount would observe, without keeping a resident metadata-block image.

pub fn as_filesystem(&self) -> &Filesystem<'static>

Returns the mounted read-only metadata view.

This is useful for metadata-only inspection such as stat, read_dir, attrs, global state, and directory usage. For file payload reads through a mutable mount, prefer FilesystemMut::read_file or file handles: CTZ data blocks intentionally stay on the owned block device and are fetched through the view’s small read cache instead of being copied into a resident metadata snapshot.

pub fn info(&self) -> &FsInfo

pub fn limits(&self) -> FilesystemLimits

pub fn directory_usage(&self, path: &str) -> Result<DirectoryUsage>

pub fn used_blocks(&self) -> Result<Vec<bool>>

pub fn read_dir(&self, path: &str) -> Result<Vec<DirEntry>>

pub fn read_dir_with<F>(&self, path: &str, visitor: F) -> Result<()>
where F: FnMut(DirEntry) -> Result<()>,

pub fn open_dir<'fs>(&'fs self, path: &str) -> Result<DirHandle<'fs, 'static>>

pub fn read_file(&self, path: &str) -> Result<Vec<u8>>

pub fn read_attr(&self, path: &str, attr_type: u8) -> Result<Vec<u8>>

pub fn read_attr_into( &self, path: &str, attr_type: u8, out: &mut [u8], ) -> Result<usize>

pub fn walk(&self, path: &str) -> Result<Vec<WalkEntry>>

pub fn walk_with<F>(&self, path: &str, visitor: F) -> Result<()>
where F: FnMut(WalkEntry) -> Result<()>,

pub fn create_file(&mut self, path: &str, data: &[u8]) -> Result<()>

Creates a file through native mounted transactions only.

The mounted API must not silently materialize the whole block device in RAM. If a path shape is not covered by the native writer yet, callers get Unsupported instead of a hidden block_size * block_count allocation.

pub fn write_file(&mut self, path: &str, data: &[u8]) -> Result<()>

Creates or replaces a file with the provided bytes through native paths.

pub fn append_file(&mut self, path: &str, data: &[u8]) -> Result<()>

pub fn rename_file(&mut self, from: &str, to: &str) -> Result<()>

Renames a file by copying visible bytes to the new path and removing the old path.

This is not yet littlefs’s atomic rename transaction. It is a deliberate mounted-API milestone that gives users same-content rename semantics on top of already C-verified create/delete operations. Power-loss tests will force this into a true atomic metadata operation later.

pub fn rename_dir(&mut self, from: &str, to: &str) -> Result<()>

pub fn remove_file(&mut self, path: &str) -> Result<()>

pub fn set_attr(&mut self, path: &str, attr_type: u8, data: &[u8]) -> Result<()>

pub fn remove_attr(&mut self, path: &str, attr_type: u8) -> Result<()>

pub fn create_dir(&mut self, path: &str) -> Result<()>

pub fn remove_dir(&mut self, path: &str) -> Result<()>

pub fn create_file_writer<'fs>( &'fs mut self, path: &str, ) -> Result<FileWriter<'fs, D>>

pub fn open_file<'fs>( &'fs mut self, path: &str, options: FileOptions, ) -> Result<FileHandle<'fs, D>>

pub fn sync(&mut self) -> Result<()>

pub fn set_block_cycles(&mut self, block_cycles: Option<u32>)

Configures the mounted metadata relocation threshold.

littlefs treats block_cycles as a wear-leveling hint: once a metadata pair has been compacted enough times, the pair should move to freshly allocated blocks and its parent should be updated to point at the new pair. None disables this mounted-writer relocation policy. The default mirrors the C fixture (128), while tests can lower the value to force relocation without hundreds of commits.

pub fn into_device(self) -> D

Trait Implementations§

§

impl<D: BlockDevice + Clone + 'static> Clone for FilesystemMut<D>

§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug + BlockDevice + 'static> Debug for FilesystemMut<D>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<D> Freeze for FilesystemMut<D>

§

impl<D> !RefUnwindSafe for FilesystemMut<D>

§

impl<D> !Send for FilesystemMut<D>

§

impl<D> !Sync for FilesystemMut<D>

§

impl<D> Unpin for FilesystemMut<D>

§

impl<D> UnsafeUnpin for FilesystemMut<D>

§

impl<D> !UnwindSafe for FilesystemMut<D>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.