Skip to content

Commit 506aac6

Browse files
authored
Merge pull request #40 from YuhanLiin/multi-heapless
Support both heapless 0.8 and 0.9
2 parents 738e718 + 9cbe22d commit 506aac6

29 files changed

Lines changed: 207 additions & 192 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
matrix:
1010
toolchain:
1111
- stable
12-
- 1.85.0
12+
- 1.88.0
1313
steps:
1414
- uses: actions/checkout@v4
1515
- uses: dtolnay/rust-toolchain@master
@@ -28,7 +28,7 @@ jobs:
2828
matrix:
2929
toolchain:
3030
- stable
31-
- 1.85.0
31+
- 1.88.0
3232
steps:
3333
- uses: actions/checkout@v4
3434
- uses: dtolnay/rust-toolchain@master
@@ -47,7 +47,7 @@ jobs:
4747
matrix:
4848
toolchain:
4949
- stable
50-
- 1.85.0
50+
- 1.88.0
5151
steps:
5252
- uses: actions/checkout@v4
5353
- uses: dtolnay/rust-toolchain@master

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@
77
- Add `encode_cache` option to enable caching of message field lengths during encoding
88
- Add `compile_protos_with_config_files` to compile proto files with corresponding config files
99
- Add new unified error type `micropb_gen::Error`
10+
- Add `micropb` support for heapless 0.9
1011

1112
### Changed
1213

13-
- Top-level APIs now return `micropb_gen::Error` instead of `io::ErrorNew`
14+
- Top-level APIs now return `micropb_gen::Error` instead of `io::Error`
15+
- Split `container-heapless` into `container-heapless-0-8` and `container-heapless-0-9`
16+
- Change `container-arrayvec` to `container-arrayvec-0-7`
17+
- `use_container_heapless` now sets `map_type` to `heapless::index_map::FnvIndexMap`, which is the correct path in v0.9
18+
- Bump MSRV to 1.88
19+
20+
### Removed
21+
22+
- Remove `micropb` re-exports of `heapless` and `arrayvec`
1423

1524
## 0.5.1
1625

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Documentation is at [docs.rs](https://docs.rs/micropb-gen/latest/micropb_gen/).
3838

3939
## MSRV
4040

41-
The oldest version of Rust that `micropb` supports is **1.85.0**.
41+
The oldest version of Rust that `micropb` supports is **1.88.0**.
4242

4343
## License
4444

examples/arm-app/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ cortex-m-rt = "0.6.10"
1111
cortex-m-semihosting = { version = "0.3.3", optional = true }
1212
panic-halt = "0.2.0"
1313

14-
micropb = { path = "../../micropb", features = ["container-heapless"] }
14+
micropb = { path = "../../micropb", features = ["container-heapless-0-9"] }
15+
heapless = "0.9"
1516

1617
[build-dependencies]
1718
micropb-gen = { path = "../../micropb-gen" }

examples/arm-app/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ use core::{hint::black_box, mem::size_of, str::FromStr};
55

66
#[cfg(feature = "formatting")]
77
use cortex_m_semihosting::{debug, hprintln};
8-
use micropb::{
9-
heapless::{String, Vec},
10-
MessageDecode, MessageEncode, PbDecoder, PbEncoder,
11-
};
8+
use heapless::{String, Vec};
9+
use micropb::{MessageDecode, MessageEncode, PbDecoder, PbEncoder};
1210
use panic_halt as _; // you can put a breakpoint on `rust_begin_unwind` to catch panics
1311

1412
use cortex_m_rt::entry;

examples/basic/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ name = "basic"
33
version = "0.1.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
86
[dependencies]
9-
micropb = { path = "../../micropb", features = ["container-heapless"] }
7+
micropb = { path = "../../micropb", features = ["container-heapless-0-9"] }
8+
heapless = "0.9"
109

1110
[build-dependencies]
1211
micropb-gen = { path = "../../micropb-gen" }

examples/basic/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
// const CAPACITY: usize = 32;
2323

2424
// Use heapless::Vec as the output stream and build an encoder around it
25-
let mut encoder = PbEncoder::new(micropb::heapless::Vec::<u8, CAPACITY>::new());
25+
let mut encoder = PbEncoder::new(heapless::Vec::<u8, CAPACITY>::new());
2626

2727
// Compute the size of the `Example` on the wire
2828
let _size = example.compute_size();

examples/no-panicking/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ version = "0.0.0"
44
edition = "2021"
55

66
[dependencies]
7-
micropb = { path = "../../micropb", features = ["container-heapless"] }
7+
micropb = { path = "../../micropb", features = ["container-heapless-0-9"] }
8+
heapless = "0.9"
89
no-panic = { version = "0.1" }
910

1011
[build-dependencies]

examples/no-panicking/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn raw_point(raw: &[u8]) -> proto::gps_::LocationData_::Point {
3434

3535
#[no_panic]
3636
fn round_trip() -> Result<(proto::gps_::LocationData, proto::gps_::LocationData), &'static str> {
37-
let mut points = micropb::heapless::Vec::new();
37+
let mut points = heapless::Vec::new();
3838
points
3939
.push(gps_point(proto::gps_::Gps {
4040
time: 165547,
@@ -57,20 +57,20 @@ fn round_trip() -> Result<(proto::gps_::LocationData, proto::gps_::LocationData)
5757
.unwrap();
5858
points.push(raw_point(b"abcdefg")).unwrap();
5959

60-
let mut time_to_type = micropb::heapless::FnvIndexMap::new();
60+
let mut time_to_type = heapless::index_map::FnvIndexMap::new();
6161
// Can't unwrap these inserts, since the compiler will generate panics here
6262
let _ = time_to_type.insert(165547, proto::gps_::LocationData_::Type::Gps);
6363
let _ = time_to_type.insert(165577, proto::gps_::LocationData_::Type::Accel);
6464
let _ = time_to_type.insert(165578, proto::gps_::LocationData_::Type::Raw);
6565

6666
let input_location = proto::gps_::LocationData {
6767
checksum: 0xDEADBEEF,
68-
comment: micropb::heapless::String::try_from("nice").unwrap(),
68+
comment: heapless::String::try_from("nice").unwrap(),
6969
points,
7070
time_to_type,
7171
};
7272

73-
let mut encoder = PbEncoder::new(micropb::heapless::Vec::<u8, 100>::new());
73+
let mut encoder = PbEncoder::new(heapless::Vec::<u8, 100>::new());
7474
input_location
7575
.encode(&mut encoder)
7676
.map_err(|_| "Encode error")?;

micropb-gen/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description = "Generate Rust module from Protobuf files"
77
keywords = ["protobuf", "no_std", "embedded", "serialization"]
88
categories = ["embedded", "no-std::no-alloc", "encoding"]
99
repository = "https://github.com/YuhanLiin/micropb"
10-
rust-version = "1.85.0"
10+
rust-version = "1.88.0"
1111
license = "MIT OR Apache-2.0"
1212

1313
[dependencies]
@@ -25,7 +25,8 @@ regex = { version = "1" }
2525
[dev-dependencies]
2626
syn = { version = "2", default-features = false, features = ["extra-traits"] }
2727
# Used for doc examples
28-
micropb = { version = "0.5.1", path = "../micropb", features = ["std", "container-heapless"] }
28+
micropb = { version = "0.5.1", path = "../micropb", features = ["std", "container-heapless-0-9"] }
29+
heapless = "0.9"
2930

3031
[features]
3132
default = ["format", "config-file"]

0 commit comments

Comments
 (0)