pub struct ImageEditor { /* private fields */ }Expand description
Explicit full-image editor for already materialized littlefs images.
This is an offline/host-side utility. Mounted APIs must not call it as a
hidden fallback because it owns a complete image Vec.
Implementations§
Source§impl ImageEditor
impl ImageEditor
pub fn open(image: Vec<u8>, cfg: Config) -> Result<Self>
pub fn used_blocks(&self) -> &[bool]
Sourcepub fn create_file(&mut self, path: &str, data: &[u8]) -> Result<&mut Self>
pub fn create_file(&mut self, path: &str, data: &[u8]) -> Result<&mut Self>
Creates a new file in an imported image.
The editor appends a normal littlefs CREATE/name/struct commit to the target metadata pair, choosing the create id by lexical order so later entries shift as they would in a directory log written by C. Small files are stored inline; larger files allocate CTZ blocks from the scanned reachable-block map and erase them before programming.
Sourcepub fn create_dir(&mut self, path: &str) -> Result<&mut Self>
pub fn create_dir(&mut self, path: &str) -> Result<&mut Self>
Creates a new root-level directory in an imported image.
The directory receives a freshly allocated metadata pair containing a valid empty commit, then the root pair gets a CREATE/name/DIRSTRUCT commit that makes the child reachable. This mirrors the two pieces C needs to open the directory after remounting.
Sourcepub fn update_inline_file(
&mut self,
path: &str,
data: &[u8],
) -> Result<&mut Self>
pub fn update_inline_file( &mut self, path: &str, data: &[u8], ) -> Result<&mut Self>
Appends an inline struct update for an existing root-level file.
Imported-image editing starts with this narrow operation because it does not need new data blocks or parent DIRSTRUCT rewrites. The update is still a real littlefs metadata commit appended to the active root side, so upstream C must be able to mount the edited image and read the new bytes.
pub fn update_file(&mut self, path: &str, data: &[u8]) -> Result<&mut Self>
pub fn update_attr( &mut self, path: &str, attr_type: u8, data: &[u8], ) -> Result<&mut Self>
pub fn delete_attr(&mut self, path: &str, attr_type: u8) -> Result<&mut Self>
pub fn delete_file(&mut self, path: &str) -> Result<&mut Self>
pub fn delete_dir(&mut self, path: &str) -> Result<&mut Self>
pub fn into_bytes(self) -> Vec<u8> ⓘ
Trait Implementations§
Source§impl Clone for ImageEditor
impl Clone for ImageEditor
Source§fn clone(&self) -> ImageEditor
fn clone(&self) -> ImageEditor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more