pub struct CursorRegion { /* private fields */ }Expand description
Address arithmetic for the two-sector cursor region.
A record occupies one page-sized slot, because a page is the smallest unit this crate can write.
Implementations§
Source§impl CursorRegion
impl CursorRegion
Sourcepub fn new(base: u32, sector_size: u32, page_size: u32) -> Result<Self, Error>
pub fn new(base: u32, sector_size: u32, page_size: u32) -> Result<Self, Error>
Describe a cursor region starting at base.
§Errors
InvalidConfigif the page cannot hold a record, if the sector is not a whole number of pages, or if fewer than two slots would fitOverflowif the region does not fit inu32address space
Sourcepub fn slots_per_sector(&self) -> u32
pub fn slots_per_sector(&self) -> u32
Slots available in one cursor sector.
Sourcepub fn total_size(&self) -> u32
pub fn total_size(&self) -> u32
Total bytes the region occupies.
Sourcepub fn sector_offset(&self, sector: u8) -> u32
pub fn sector_offset(&self, sector: u8) -> u32
Sourcepub fn sector_range(&self, sector: u8) -> (u32, u32)
pub fn sector_range(&self, sector: u8) -> (u32, u32)
The half-open offset range one cursor sector occupies, for an erase.
Region-relative, like every other offset here. It exists so the erase
bound is stated once: the two drivers had derived the same range by
different arithmetic — total_size() / 2 against
total_size() / CURSOR_SECTORS — which agree only for as long as
CURSOR_SECTORS stays 2.
Sourcepub fn slot_offset(&self, sector: u8, slot: u32) -> u32
pub fn slot_offset(&self, sector: u8, slot: u32) -> u32
Offset of a slot within the region. Region-relative; see
sector_offset.
Sourcepub fn slots(&self) -> impl Iterator<Item = SlotAddress> + '_
pub fn slots(&self) -> impl Iterator<Item = SlotAddress> + '_
Every slot in the region, in address order.
The scan has to read all of them — a resume point can be justified by any record, and a torn slot in the middle still consumes its place — so the traversal itself carries no decisions and belongs here rather than in a driver’s nested loop.
Trait Implementations§
Source§impl Clone for CursorRegion
impl Clone for CursorRegion
impl Copy for CursorRegion
Source§impl Debug for CursorRegion
impl Debug for CursorRegion
impl Eq for CursorRegion
Source§impl Format for CursorRegion
Available on crate feature defmt only.
impl Format for CursorRegion
defmt only.