pub struct Partition<F> { /* private fields */ }Expand description
A NorFlash view of [base, base + len) of an underlying device.
Offsets passed to the flash traits are relative to base, and the
reported capacity is
len. Alignment granularity, and every error the device itself raises, pass
through unchanged.
See the module documentation for why the two constructors exist.
Implementations§
Source§impl<F: NorFlash> Partition<F>
impl<F: NorFlash> Partition<F>
Sourcepub fn new(inner: F, base: u32, len: u32) -> Result<Self, Error>
pub fn new(inner: F, base: u32, len: u32) -> Result<Self, Error>
Create a partition covering [base, base + len) of inner.
§Errors
InvalidConfigiflenis zero, ifbaseorlenis not a multiple of the device’s erase, write and read granularity, or if the range runs past the device’s capacityOverflowifbase + lendoes not fit inu32
Source§impl<F: NorFlash> Partition<F>
impl<F: NorFlash> Partition<F>
Sourcepub fn new_async(inner: F, base: u32, len: u32) -> Result<Self, Error>
Available on crate feature async only.
pub fn new_async(inner: F, base: u32, len: u32) -> Result<Self, Error>
async only.Create a partition over a device implementing the async flash traits.
Not an async fn — see the module documentation for why the
suffix is there. Validation is otherwise identical to
new.
Source§impl<F> Partition<F>
impl<F> Partition<F>
Sourcepub const fn base(&self) -> u32
pub const fn base(&self) -> u32
First byte of the partition in the underlying device’s address space.
Sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Whether the partition is empty. Never true — a zero length is rejected
at construction — but clippy asks for it wherever len exists.
Sourcepub const fn contains(&self, addr: u32) -> bool
pub const fn contains(&self, addr: u32) -> bool
Whether addr, an address in the underlying device’s space, falls
inside this partition.
Sourcepub const fn inner_mut(&mut self) -> &mut F
pub const fn inner_mut(&mut self) -> &mut F
Borrow the underlying device mutably.
This is the escape hatch out of the partition, and it is deliberately explicit: everything reached through here is addressed in the device’s space, with no bound of any kind.
Sourcepub fn into_inner(self) -> F
pub fn into_inner(self) -> F
Consume the partition and return the underlying device.
Trait Implementations§
Source§impl<F: NorFlash> NorFlash for Partition<F>
impl<F: NorFlash> NorFlash for Partition<F>
Source§const WRITE_SIZE: usize = F::WRITE_SIZE
const WRITE_SIZE: usize = F::WRITE_SIZE
Source§const ERASE_SIZE: usize = F::ERASE_SIZE
const ERASE_SIZE: usize = F::ERASE_SIZE
Source§impl<F: NorFlash> NorFlash for Partition<F>
Available on crate feature async only.
impl<F: NorFlash> NorFlash for Partition<F>
async only.Source§const WRITE_SIZE: usize = F::WRITE_SIZE
const WRITE_SIZE: usize = F::WRITE_SIZE
Source§const ERASE_SIZE: usize = F::ERASE_SIZE
const ERASE_SIZE: usize = F::ERASE_SIZE
Source§impl<F: ReadNorFlash> ReadNorFlash for Partition<F>
impl<F: ReadNorFlash> ReadNorFlash for Partition<F>
Source§const READ_SIZE: usize = F::READ_SIZE
const READ_SIZE: usize = F::READ_SIZE
Source§impl<F: ReadNorFlash> ReadNorFlash for Partition<F>
Available on crate feature async only.
impl<F: ReadNorFlash> ReadNorFlash for Partition<F>
async only.