Skip to content

Conversation

@ringlej
Copy link
Collaborator

@ringlej ringlej commented Jan 14, 2026

Summary

  • Add streaming encode support in the core library, including callback-backed output, indefinite-length containers, and streaming-specific errors
  • Add generator support for streaming entrypoints (cbor_stream_encode_*) and provider structs, plus stream-aware type handling
  • Document the streaming codegen option and provider model in README/architecture
  • Add STREAMING=1 encode suite coverage and route tests through streaming entrypoints

Justification

  • Enables low-RAM producers to stream CBOR without precomputing container sizes
  • Keeps existing buffered encoding unchanged unless streaming entrypoints are used
  • Provides iterator/chunk provider hooks so repeated fields and long strings can be streamed safely

Testing

  • west twister -T tests -p native_sim

@ringlej ringlej requested a review from abelino January 14, 2026 21:24
Add an encode mode that writes CBOR bytes directly to a caller-provided callback
instead of an intermediate output buffer. This enables low-RAM producers (e.g.
UART streaming) to emit CBOR without needing to precompute container sizes.

The encode implementation routes all byte writes through helper macros that
either append to the payload buffer (existing behavior) or call the streaming
callback (streaming mode). When streaming is enabled, list/map containers are
terminated using indefinite-length encoding (break 0xFF) to avoid backtracking
and header resizing.

Also add helper APIs for iterator-driven repeated-field encoding and chunked
indefinite-length text string encoding, plus error reporting for streaming
write/provider failures.

Backward compatible: NULL callback retains existing buffered encoding.
Add optional generation of streaming encode entrypoints (cbor_stream_encode_<type>) and provider structs for repeated fields (iterator) and tstr chunking.

Keep default generated output unchanged unless --stream-encode-functions is enabled, and keep repeated fields as fixed arrays unless --repeated-as-pointers is enabled.
Document the optional streaming encode entrypoints and the --stream-encode-functions codegen option.

Update the architecture overview to mention the generated provider structs and streaming entrypoints.
- Add STREAMING=1 variants for test1_suit, test2_simple, test3_corner_cases, and test4_senml.
- Exercise streaming encode paths via stream_write helpers and cbor_stream_encode_* entrypoints.
@ringlej ringlej closed this Jan 17, 2026
@ringlej ringlej reopened this Jan 17, 2026
@ringlej ringlej closed this Jan 26, 2026
@ringlej ringlej deleted the streaming-support branch January 29, 2026 15:04
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.

1 participant