pub struct EspWlPartition<T> { /* private fields */ }Expand description
Represents a partition wrapped with the ESP-IDF Wear-Leveling algorithm
Implementations§
Source§impl<T> EspWlPartition<T>where
T: BorrowMut<EspPartition>,
impl<T> EspWlPartition<T>where
T: BorrowMut<EspPartition>,
Sourcepub fn new(partition: T) -> Result<Self, EspError>
pub fn new(partition: T) -> Result<Self, EspError>
Wrap the provided raw partition with the ESP-IDF Wear-Leveling algorithm
Return an error if the wrap operation failed, or the WL partition if the operation succeeded.
Arguments:
partition: The partition to mount
Sourcepub fn sector_size(&self) -> usize
pub fn sector_size(&self) -> usize
Return the size of a sector in the mounted WL partition
Sourcepub fn read(&mut self, offset: usize, buf: &mut [u8]) -> Result<(), EspError>
pub fn read(&mut self, offset: usize, buf: &mut [u8]) -> Result<(), EspError>
Read data from the mounted WL partition
§Arguments
offset: The offset in the partition to read from, in bytesbuf: The buffer to read the data into
Return an error if the read operation failed. The read operation would fail if the offset and buffer length are beyond the partition bounds.
The read operation will also fail if the offset and the buffer length are not aligned with the partition read alignment.
Sourcepub fn write(&mut self, offset: usize, data: &[u8]) -> Result<(), EspError>
pub fn write(&mut self, offset: usize, data: &[u8]) -> Result<(), EspError>
Write data to the mounted WL partition
§Arguments
offset: The offset in the partition to write to, in bytesdata: The data to write to the partition
Return an error if the write operation failed. The write operation would fail if the offset and data length are beyond the partition bounds.
The write operation will also fail if the offset and the data length are not aligned with the partition write alignment.
Sourcepub fn erase(&mut self, offset: usize, size: usize) -> Result<(), EspError>
pub fn erase(&mut self, offset: usize, size: usize) -> Result<(), EspError>
Erase a region of the mounted WL partition
§Arguments
offset: The offset in the partition to start erasing from, in bytessize: The size of the region to erase, in bytes
Return an error if the erase operation failed. The erase operation would fail if the offset and size are beyond the partition bounds.