Struct Geometry
pub struct Geometry {
block_count: u32,
block_size: u32,
page_size: u32,
}Expand description
Size, erase block size and page size of an MTD device.
Holding a Geometry proves that the sizes are usable: pages and blocks are
not empty, a block is a whole number of pages and the device is a whole
number of blocks.
Fields§
§block_count: u32§block_size: u32§page_size: u32Implementations§
§impl Geometry
impl Geometry
pub(crate) fn new(
size: u64,
block_size: u32,
page_size: u32,
) -> Result<Self, DeviceError>
pub(crate) fn new( size: u64, block_size: u32, page_size: u32, ) -> Result<Self, DeviceError>
Validates the sizes reported by the device.
pub const fn block_count(&self) -> u32
pub const fn block_count(&self) -> u32
Returns the number of erase blocks.
pub const fn block_size(&self) -> u32
pub const fn block_size(&self) -> u32
Returns the erase block size in bytes.
pub(crate) fn offset(&self, block: u32) -> Result<u64, DeviceError>
pub(crate) fn offset(&self, block: u32) -> Result<u64, DeviceError>
Returns the byte offset of block after checking its range.
pub(crate) fn read_offset(
&self,
block: u32,
offset: u32,
len: usize,
) -> Result<u64, DeviceError>
pub(crate) fn read_offset( &self, block: u32, offset: u32, len: usize, ) -> Result<u64, DeviceError>
Returns the byte offset of a read of len bytes from block, starting
offset bytes into it.
pub(crate) fn write_offset(
&self,
block: u32,
len: usize,
) -> Result<u64, DeviceError>
pub(crate) fn write_offset( &self, block: u32, len: usize, ) -> Result<u64, DeviceError>
Returns the byte offset of block for a write of len bytes.
Trait Implementations§
impl Copy for Geometry
impl Eq for Geometry
impl StructuralPartialEq for Geometry
Auto Trait Implementations§
impl Freeze for Geometry
impl RefUnwindSafe for Geometry
impl Send for Geometry
impl Sync for Geometry
impl Unpin for Geometry
impl UnsafeUnpin for Geometry
impl UnwindSafe for Geometry
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