ciborium icon indicating copy to clipboard operation
ciborium copied to clipboard

[Feature]: Streaming support in `ciborium_ll`

Open 01mf02 opened this issue 5 months ago • 0 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Description

The CBOR RFC specifies that CBOR can be used in streaming applications:

In a streaming application, a data stream may be composed of a sequence of CBOR data items concatenated back-to-back. In such an environment, the decoder immediately begins decoding a new data item if data is found after the end of a previous data item.

I would like to use this in my program jaq, where I have already integrated support for CBOR via ciborium_ll. However, I have hit the limitation that ciborium_ll::Decoder::pull does not allow me to distinguish between EOF and syntax errors. As a result, I have not found a way to properly support CBOR streaming in my application.

Acceptance Criteria

No response

Suggestions for a technical implementation

I see two realistic options:

  • Create a version of Decoder::pull() that returns Option<Result<Header, Error<R::Error>>> instead of Result<Header, Error<R::Error>>. We could call this function next() and then also just implement Iterator for Decoder. :)
  • Enhance the ciborium_ll::Error type with an Eof variant.

If you give me a green light for one of these two options, I would be also motivated to implement this change myself.

01mf02 avatar Jul 25 '25 10:07 01mf02