pub struct EspPartition(/* private fields */);Expand description
Represents a partition in the ESP32 flash memory
Implementations§
Source§impl EspPartition
impl EspPartition
Sourcepub unsafe fn wrap(partition: *const esp_partition_t) -> Self
pub unsafe fn wrap(partition: *const esp_partition_t) -> Self
Wrap a raw pointer into an EspPartition instance
§Safety
The raw pointer should be a valid one
It should not be shared in multiple EspPartition instances
Sourcepub unsafe fn new(label: &str) -> Result<Option<Self>, EspError>
pub unsafe fn new(label: &str) -> Result<Option<Self>, EspError>
Create a new EspPartition instance for an existing partition identified by its label
§Arguments
label: The label of the partition
Return None if the partition with the label does not exist
or Some with the partition if it exists.
§Safety
Only a single partition should be active at any point in time for that label.
Sourcepub unsafe fn cnew(clabel: &CStr) -> Result<Option<Self>, EspError>
pub unsafe fn cnew(clabel: &CStr) -> Result<Option<Self>, EspError>
Create a new EspPartition instance for an existing partition identified by its C-string label
§Arguments
clabel: The label of the partition as a C string
Return None if the partition with the label does not exist
or Some with the partition if it exists.
§Safety
Only a single partition should be active at any point in time for that label.
Sourcepub unsafe fn find_first(
partition_type: EspPartitionType,
) -> Result<Option<Self>, EspError>
pub unsafe fn find_first( partition_type: EspPartitionType, ) -> Result<Option<Self>, EspError>
Find and return the first partition of a specific type
§Arguments
partition_type: The type of the partition to find
Return None if a partition of the specified type does not exist
or Some with the first partition of the specified type if it exists.
§Safety
User should not end up with two EspPartition instances representing the same ESP IDF partition.
Sourcepub fn partition_type(&self) -> EspPartitionType
pub fn partition_type(&self) -> EspPartitionType
Return the type of the partition
Sourcepub fn erase_size(&self) -> usize
pub fn erase_size(&self) -> usize
Return the erase size block of the partition in bytes
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 partition, performing decryption of the data if the partition is encrypted.
§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 partition, performing encryption of the data if the partition is encrypted.
§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 partition
§Arguments
offset: The offset in the partition to start erasing from, in bytessize: The size of the region to erase
Return an error if the erase operation failed. The erase operation would fail if the offset and size are beyond the partition bounds.
The erase operation will also fail if the offset and the size
are not aligned with the partition erase block returned by erase_size.
Sourcepub fn read_raw(
&mut self,
offset: usize,
buf: &mut [u8],
) -> Result<(), EspError>
pub fn read_raw( &mut self, offset: usize, buf: &mut [u8], ) -> Result<(), EspError>
Read data from the partition without performing decryption
Identical to read if the partition is not encrypted.
Sourcepub fn write_raw(&mut self, offset: usize, data: &[u8]) -> Result<(), EspError>
pub fn write_raw(&mut self, offset: usize, data: &[u8]) -> Result<(), EspError>
Write data to the partition without performing encryption
Identical to write if the partition is not encrypted.