Skip to main content

Straddle

Enum Straddle 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Trait Implementations§

Source§

impl Clone for Straddle

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Straddle

Source§

impl Debug for Straddle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Straddle

Source§

impl PartialEq for Straddle

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Straddle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.