Update to heapless 0.9

This commit is contained in:
Sosthène Guédon
2025-09-26 11:53:26 +02:00
committed by Sosthène Guédon
parent 97b91369c4
commit e9d3a1ca98
4 changed files with 29 additions and 3 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ repository = "https://github.com/trussed-dev/littlefs2"
[package]
name = "littlefs2"
description = "Idiomatic Rust API for littlefs"
version = "0.6.1"
version = "0.7.0"
authors = ["Nicolas Stalder <n@stalder.io>", "Brandon Edens <brandonedens@gmail.com>", "The Trussed developers"]
readme = "README.md"
categories = ["embedded", "filesystem", "no-std"]
@@ -26,7 +26,7 @@ all-features = true
bitflags = "2.9.0"
delog = "0.1.0"
generic-array = "0.14"
heapless = "0.7"
heapless = "0.9"
littlefs2-core = { version = "0.1", path = "core" }
littlefs2-sys = { version = "0.3.1", features = ["multiversion"] }
+4
View File
@@ -12,14 +12,18 @@ repository.workspace = true
bitflags = "2.6.0"
heapless-bytes03 = { package = "heapless-bytes", version = "0.3", optional = true }
heapless-bytes04 = { package = "heapless-bytes", version = "0.4", optional = true }
heapless-bytes05 = { package = "heapless-bytes", version = "0.5", optional = true }
heapless07 = { package = "heapless", version = "0.7", optional = true }
heapless08 = { package = "heapless", version = "0.8", optional = true }
heapless09 = { package = "heapless", version = "0.9", optional = true }
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
[features]
heapless-bytes03 = ["dep:heapless-bytes03"]
heapless-bytes04 = ["dep:heapless-bytes04"]
heapless-bytes05 = ["dep:heapless-bytes05"]
heapless07 = ["dep:heapless07"]
heapless08 = ["dep:heapless08"]
heapless09 = ["dep:heapless09"]
serde = ["dep:serde"]
debug-error = []
+22
View File
@@ -42,6 +42,17 @@ impl<const N: usize> Vec for heapless_bytes04::Bytes<N> {
}
}
#[cfg(feature = "heapless-bytes05")]
impl<const N: usize> Vec for heapless_bytes05::Bytes<N> {
fn resize_to_capacity(&mut self) {
heapless_bytes05::Bytes::resize_to_capacity(self)
}
fn truncate(&mut self, n: usize) {
heapless_bytes05::Bytes::truncate(self, n)
}
}
#[cfg(feature = "heapless07")]
impl<const N: usize> Vec for heapless07::Vec<u8, N> {
fn resize_to_capacity(&mut self) {
@@ -64,6 +75,17 @@ impl<const N: usize> Vec for heapless08::Vec<u8, N> {
}
}
#[cfg(feature = "heapless09")]
impl<LenT: heapless09::LenType, const N: usize> Vec for heapless09::Vec<u8, N, LenT> {
fn resize_to_capacity(&mut self) {
self.resize_default(self.capacity()).unwrap();
}
fn truncate(&mut self, n: usize) {
heapless09::Vec::truncate(self, n)
}
}
/// Object-safe trait for files.
///
/// The methods for opening files cannot be implemented in this trait. Use these methods instead:
+1 -1
View File
@@ -744,7 +744,7 @@ impl<'a, 'b, Storage: driver::Storage> File<'a, 'b, Storage> {
}
// This belongs in `io::Read` but really don't want that to have a generic parameter
pub fn read_to_end<const N: usize>(&self, buf: &mut heapless::Vec<u8, N>) -> Result<usize> {
pub fn read_to_end(&self, buf: &mut heapless::VecView<u8>) -> Result<usize> {
// My understanding of
// https://github.com/littlefs-project/littlefs/blob/4c9146ea539f72749d6cc3ea076372a81b12cb11/lfs.c#L2816
// is that littlefs keeps reading until either the buffer is full, or the file is exhausted