Replace unsafe with new std API (#4178)

* Replace unsafe with new std API

* bump

* Fix link in readme

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
This commit is contained in:
Dominic Fischer 2025-09-25 01:36:26 -06:00 committed by GitHub
parent c233ca70fe
commit a47f0b8a4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 11 deletions

View File

@ -2,7 +2,7 @@
name = "esp-bootloader-esp-idf"
version = "0.2.0"
edition = "2024"
rust-version = "1.86.0"
rust-version = "1.88.0"
description = "Functionality related to the esp-idf bootloader"
documentation = "https://docs.espressif.com/projects/rust/esp-bootloader-esp-idf/latest/"
keywords = ["esp32", "espressif", "no-std"]

View File

@ -2,7 +2,7 @@
[![Crates.io](https://img.shields.io/crates/v/esp-bootloader-esp-idf?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/esp-bootloader-esp-idf)
[![docs.rs](https://img.shields.io/docsrs/esp-bootloader-esp-idf?labelColor=1C2C2E&color=C96329&logo=rust&style=flat-square)](https://docs.espressif.com/projects/rust/esp-bootloader-esp-idf/latest/)
![MSRV](https://img.shields.io/badge/MSRV-1.86.0-blue?labelColor=1C2C2E&style=flat-square)
![MSRV](https://img.shields.io/badge/MSRV-1.88.0-blue?labelColor=1C2C2E&style=flat-square)
![Crates.io](https://img.shields.io/crates/l/esp-bootloader-esp-idf?labelColor=1C2C2E&style=flat-square)
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)

View File

@ -199,7 +199,8 @@ impl<'a> PartitionTable<'a> {
return Err(Error::Invalid);
}
if binary.len() % RAW_ENTRY_LEN != 0 {
let (binary, rem) = binary.as_chunks::<RAW_ENTRY_LEN>();
if !rem.is_empty() {
return Err(Error::Invalid);
}
@ -210,14 +211,6 @@ impl<'a> PartitionTable<'a> {
});
}
// we checked binary before
let binary = unsafe {
core::slice::from_raw_parts(
binary.as_ptr() as *const [u8; RAW_ENTRY_LEN],
binary.len() / RAW_ENTRY_LEN,
)
};
let mut raw_table = Self {
binary,
entries: binary.len(),