Skip to content

Commit 62e5aa6

Browse files
Update to heapless 0.9
1 parent 97b9136 commit 62e5aa6

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ all-features = true
2626
bitflags = "2.9.0"
2727
delog = "0.1.0"
2828
generic-array = "0.14"
29-
heapless = "0.7"
29+
heapless = "0.9"
3030
littlefs2-core = { version = "0.1", path = "core" }
3131
littlefs2-sys = { version = "0.3.1", features = ["multiversion"] }
3232

core/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ repository.workspace = true
1212
bitflags = "2.6.0"
1313
heapless-bytes03 = { package = "heapless-bytes", version = "0.3", optional = true }
1414
heapless-bytes04 = { package = "heapless-bytes", version = "0.4", optional = true }
15+
heapless-bytes05 = { package = "heapless-bytes", version = "0.5", optional = true }
1516
heapless07 = { package = "heapless", version = "0.7", optional = true }
1617
heapless08 = { package = "heapless", version = "0.8", optional = true }
18+
heapless09 = { package = "heapless", version = "0.9", optional = true }
1719
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
1820

1921
[features]
2022
heapless-bytes03 = ["dep:heapless-bytes03"]
2123
heapless-bytes04 = ["dep:heapless-bytes04"]
24+
heapless-bytes05 = ["dep:heapless-bytes05"]
2225
heapless07 = ["dep:heapless07"]
2326
heapless08 = ["dep:heapless08"]
27+
heapless09 = ["dep:heapless09"]
2428
serde = ["dep:serde"]
2529
debug-error = []

core/src/object_safe.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ impl<const N: usize> Vec for heapless_bytes04::Bytes<N> {
4242
}
4343
}
4444

45+
#[cfg(feature = "heapless-bytes05")]
46+
impl<const N: usize> Vec for heapless_bytes05::Bytes<N> {
47+
fn resize_to_capacity(&mut self) {
48+
heapless_bytes05::Bytes::resize_to_capacity(self)
49+
}
50+
51+
fn truncate(&mut self, n: usize) {
52+
heapless_bytes05::Bytes::truncate(self, n)
53+
}
54+
}
55+
4556
#[cfg(feature = "heapless07")]
4657
impl<const N: usize> Vec for heapless07::Vec<u8, N> {
4758
fn resize_to_capacity(&mut self) {
@@ -64,6 +75,17 @@ impl<const N: usize> Vec for heapless08::Vec<u8, N> {
6475
}
6576
}
6677

78+
#[cfg(feature = "heapless09")]
79+
impl<LenT: heapless09::LenType, const N: usize> Vec for heapless09::Vec<u8, N, LenT> {
80+
fn resize_to_capacity(&mut self) {
81+
self.resize_default(self.capacity()).unwrap();
82+
}
83+
84+
fn truncate(&mut self, n: usize) {
85+
heapless09::Vec::truncate(self, n)
86+
}
87+
}
88+
6789
/// Object-safe trait for files.
6890
///
6991
/// The methods for opening files cannot be implemented in this trait. Use these methods instead:

src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ impl<'a, 'b, Storage: driver::Storage> File<'a, 'b, Storage> {
744744
}
745745

746746
// This belongs in `io::Read` but really don't want that to have a generic parameter
747-
pub fn read_to_end<const N: usize>(&self, buf: &mut heapless::Vec<u8, N>) -> Result<usize> {
747+
pub fn read_to_end(&self, buf: &mut heapless::VecView<u8>) -> Result<usize> {
748748
// My understanding of
749749
// https://github.com/littlefs-project/littlefs/blob/4c9146ea539f72749d6cc3ea076372a81b12cb11/lfs.c#L2816
750750
// is that littlefs keeps reading until either the buffer is full, or the file is exhausted

0 commit comments

Comments
 (0)