pub struct FileFlash { /* private fields */ }Implementations§
Source§impl FileFlash
impl FileFlash
Sourcepub fn new(
file: File,
capacity: u32,
page_size: usize,
block_size: usize,
durability: Durability,
) -> Result<Self, Error>
pub fn new( file: File, capacity: u32, page_size: usize, block_size: usize, durability: Durability, ) -> Result<Self, Error>
Examples found in repository?
examples/slate_flash_calib.rs (line 58)
49fn time_flash_programs(dir: &std::path::Path, label: &str, dur: Durability) {
50 let path = dir.join(format!("calib_{label}.bin"));
51 let file = OpenOptions::new()
52 .read(true)
53 .write(true)
54 .create(true)
55 .truncate(false)
56 .open(&path)
57 .unwrap();
58 let mut flash = FileFlash::new(file, CAPACITY, PAGE, BLOCK, dur).unwrap();
59 let buf = [0xA5u8; PAGE];
60 let mut ns = Vec::with_capacity(N);
61 // Each page may be programmed once, so every iteration targets a fresh
62 // page rather than re-erasing (an erase is a different cost).
63 for i in 0..N {
64 let addr = (i * PAGE) as u32;
65 let t0 = Instant::now();
66 flash.program(addr, &buf).unwrap();
67 ns.push(t0.elapsed().as_nanos() as u64);
68 }
69 summarize(&format!("FileFlash::program,{label}"), ns);
70 drop(flash);
71 let _ = std::fs::remove_file(&path);
72}Sourcepub fn counters(&self) -> FlashCounters
pub fn counters(&self) -> FlashCounters
Device I/O tallies accumulated since this handle was created.
Trait Implementations§
Source§impl Flash for FileFlash
impl Flash for FileFlash
Source§type Error = FileFlashError
type Error = FileFlashError
Flash error type.
Source§fn block_size(&self) -> usize
fn block_size(&self) -> usize
Erase granularity, multiple of page_size.
Auto Trait Implementations§
impl Freeze for FileFlash
impl RefUnwindSafe for FileFlash
impl Send for FileFlash
impl Sync for FileFlash
impl Unpin for FileFlash
impl UnsafeUnpin for FileFlash
impl UnwindSafe for FileFlash
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