Skip to content

Add serialization support for heapless v0.8 and v0.9#295

Open
mandrean wants to merge 1 commit intojamesmunns:mainfrom
mandrean:fix/heapless-v08-v09-serialization
Open

Add serialization support for heapless v0.8 and v0.9#295
mandrean wants to merge 1 commit intojamesmunns:mainfrom
mandrean:fix/heapless-v08-v09-serialization

Conversation

@mandrean
Copy link

@mandrean mandrean commented Mar 19, 2026

Summary

Extends PR #269 (which added MaxSize impls for heapless v0.8/v0.9) with full serialization support, so users can completely migrate off heapless 0.7 and its unmaintained atomic-polyfill dependency (RUSTSEC-2023-0089).

  • Add HVecV0_8 and HVecV0_9 serialization flavors mirroring the existing HVec
  • Add convenience functions: to_vec_v0_8, to_vec_cobs_v0_8, to_vec_v0_9, to_vec_cobs_v0_9
  • Add CRC convenience functions: to_vec_crc32_v0_8, to_vec_crc32_v0_9
  • Re-export all new functions from lib.rs

Users can now fully drop heapless 0.7 with:

postcard = { version = "1", default-features = false, features = ["heapless-v0_9"] }

A note on semver compatibility

PR #269 explicitly left out serialization support, noting: "This doesn't touch to_vec or similar methods; I don't see a way of editing those without breaking semver."

That concern would apply if we were changing the existing to_vec signature or its return type. However, this PR takes a different approach: it adds new functions with versioned names (to_vec_v0_9, to_vec_cobs_v0_9, etc.) alongside the existing ones. No existing function signatures, types, or behaviors are modified. Adding new public items to a crate is a minor (non-breaking) change under semver.

Closes #223

Test plan

  • cargo build -p postcard --no-default-features --features heapless-v0_8 — builds clean
  • cargo build -p postcard --no-default-features --features heapless-v0_9 — builds clean
  • cargo build -p postcard --features heapless-v0_8,heapless-v0_9 — all heapless versions coexist
  • cargo test -p postcard --no-default-features --features heapless-v0_9 — 14 tests pass (new v0.9 tests + existing non-heapless tests)
  • cargo test -p postcard --no-default-features --features heapless-v0_8 — 10 tests pass (new v0.8 tests + existing non-heapless tests)
  • New tests cover: basic types, structs, enums, strings, byte slices, buffer-full error, COBS round-trip

@netlify
Copy link

netlify bot commented Mar 19, 2026

Deploy Preview for cute-starship-2d9c9b canceled.

Name Link
🔨 Latest commit edca451
🔍 Latest deploy log https://app.netlify.com/projects/cute-starship-2d9c9b/deploys/69bc8d91f96c24000865f572

@mandrean mandrean marked this pull request as draft March 19, 2026 23:10
@mandrean mandrean force-pushed the fix/heapless-v08-v09-serialization branch 2 times, most recently from 3816033 to 8fb6847 Compare March 19, 2026 23:30
Add HVecV0_8 and HVecV0_9 flavors, convenience functions
(to_vec_v0_8, to_vec_v0_9, to_vec_cobs_v0_8, to_vec_cobs_v0_9),
CRC convenience functions (to_vec_crc32_v0_8, to_vec_crc32_v0_9),
and re-exports in lib.rs. This allows users to fully migrate off
heapless 0.7 (and its unmaintained atomic-polyfill dependency,
RUSTSEC-2023-0089) by using default-features = false with
heapless-v0_8 or heapless-v0_9 feature flags.

Refs: jamesmunns#223
@mandrean mandrean force-pushed the fix/heapless-v08-v09-serialization branch from 8fb6847 to edca451 Compare March 19, 2026 23:58
@mandrean mandrean marked this pull request as ready for review March 19, 2026 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUSTSEC-2023-0089: Unmaintained warning, because of atomic-polyfill -> heapless dependency

1 participant