#[non_exhaustive]pub enum Straddle {
Clip,
Reject,
}Expand description
What to do with a free run that crosses out of the regions it was found in.
The two are different safety decisions, not two spellings of one, so this is explicit rather than defaulted in a way that suits one caller.
§Which regions
The ones you passed, and nothing else. This is worth stating outright
because the wording below invites the other reading:
Reject’s rationale mentions erase granularity, which
sounds as though the crate consults an erase-block map. It does not, and
cannot — it is handed a &[u8] with no device geometry, no flash
controller, and no idea what a page is on your part.
So a “region” is whatever you meant it to be: an integrity-covered span, a CMAC-protected table, an erase block, a linker-script section. The two variants differ only in whether a run may be offered when it extends past one of them.
Erase granularity is a reason you might choose Reject, not something
this crate detects. If a page on your part is coarser than the regions you
are passing, that is a fact about the part which has to be reflected in the
regions themselves; nothing here can discover it.
Every “region” in this crate works this way — find_free_space_in,
FreeSpace, and detour_in all take the
caller’s declaration and never infer one.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Clip
Truncate the run to the region. The offset handed back always has its
len bytes inside a region you named, so the placement is safe even
though the erased run it came from was not entirely covered.
Reject
Do not offer a run that extends past the region at all.
Use this when writing near a boundary is unsafe even if the bytes written are inside it — most often because erase granularity is coarser than the regions, so programming a page that straddles the boundary disturbs bytes outside it. Clipping cannot protect against that, because the hazard is the write, not the placement.