pub struct Flash { /* private fields */ }Expand description
Simulated NOR Flash storage
Implementations§
Source§impl Flash
impl Flash
Sourcepub fn with_config(config: FlashConfig) -> Self
pub fn with_config(config: FlashConfig) -> Self
Create with custom configuration
Sourcepub fn erase_page(&mut self, page: PageId) -> Result<()>
pub fn erase_page(&mut self, page: PageId) -> Result<()>
Erase a page (sets all bytes to 0xFF)
§Errors
Returns error if page index is out of range or max erase cycles exceeded
Sourcepub fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>
pub fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>
Write data to flash
Flash can only change bits from 1 to 0, not 0 to 1. Attempting to set a bit from 0 to 1 returns an error.
Sourcepub fn get_erase_count(&self, page: PageId) -> Option<u32>
pub fn get_erase_count(&self, page: PageId) -> Option<u32>
Get erase count for a page
Sourcepub fn find_wear_leveled_pages(&self, count: usize) -> Vec<PageId>
pub fn find_wear_leveled_pages(&self, count: usize) -> Vec<PageId>
Find pages with lowest erase counts (for wear leveling)
Sourcepub fn total_erase_cycles(&self) -> u64
pub fn total_erase_cycles(&self) -> u64
Get total erase cycles across all pages
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Flash
impl RefUnwindSafe for Flash
impl Send for Flash
impl Sync for Flash
impl Unpin for Flash
impl UnsafeUnpin for Flash
impl UnwindSafe for Flash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more