pub struct MemFlash { /* private fields */ }Expand description
In-memory NOR flash that simulates real flash semantics:
- Erased state is all
0xFF. - Writes can only flip bits from 1 → 0 (bitwise AND).
- Erases restore a full sector to
0xFF. - Read/write alignment is 4 bytes (word size).
- Erase granularity is 4096 bytes (sector size).
Implementations§
Source§impl MemFlash
impl MemFlash
Sourcepub fn new(pages: usize) -> Self
pub fn new(pages: usize) -> Self
Create a fresh flash of the given number of pages, filled with 0xFF.
Sourcepub fn from_bytes(data: Vec<u8>) -> Self
pub fn from_bytes(data: Vec<u8>) -> Self
Wrap existing binary data as a flash image.
The data length must be a multiple of FLASH_SECTOR_SIZE.
§Panics
Panics if data.len() is not a multiple of FLASH_SECTOR_SIZE.
Sourcepub fn into_inner(self) -> Vec<u8> ⓘ
pub fn into_inner(self) -> Vec<u8> ⓘ
Consume the flash and return the underlying buffer.
Trait Implementations§
Source§impl ErrorType for MemFlash
impl ErrorType for MemFlash
Source§type Error = MemFlashError
type Error = MemFlashError
Errors returned by this NOR flash.
Source§impl NorFlash for MemFlash
impl NorFlash for MemFlash
Source§const WRITE_SIZE: usize = WORD_SIZE
const WRITE_SIZE: usize = WORD_SIZE
The minumum number of bytes the storage peripheral can write
Source§const ERASE_SIZE: usize = FLASH_SECTOR_SIZE
const ERASE_SIZE: usize = FLASH_SECTOR_SIZE
The minumum number of bytes the storage peripheral can erase
Source§impl ReadNorFlash for MemFlash
impl ReadNorFlash for MemFlash
Source§const READ_SIZE: usize = WORD_SIZE
const READ_SIZE: usize = WORD_SIZE
The minumum number of bytes the storage peripheral can read
Auto Trait Implementations§
impl Freeze for MemFlash
impl RefUnwindSafe for MemFlash
impl Send for MemFlash
impl Sync for MemFlash
impl Unpin for MemFlash
impl UnsafeUnpin for MemFlash
impl UnwindSafe for MemFlash
Blanket Implementations§
Source§impl<T> AlignedOps for Twhere
T: Platform,
impl<T> AlignedOps for Twhere
T: Platform,
fn align_read(size: usize) -> usize
fn align_write_ceil(size: usize) -> usize
fn align_write_floor(size: usize) -> usize
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