pub struct CborSeqChunkDecoder { /* private fields */ }Expand description
Stateful boundary scanner for application/cbor-seq streams. Bytes
arrive in arbitrary chunks; this type buffers them and emits the
byte ranges of any complete top-level CBOR items observed so far.
The CBOR-level parse uses minicbor::Decoder::skip for boundary
detection (cheap, doesn’t allocate); the per-item serde decode
happens at the caller’s leisure on each returned slice.
Exposed publicly so non-RuntimeHandle callers — e.g. apps that
run the HTTP request themselves (dio in Flutter, fetch in Wasm,
platform networking on iOS/Android) — can reuse the
boundary-detection logic without re-implementing it.
Implementations§
Source§impl CborSeqChunkDecoder
impl CborSeqChunkDecoder
pub fn new() -> Self
Sourcepub fn feed_chunk(&mut self, chunk: &[u8]) -> Result<Vec<Vec<u8>>, CoolError>
pub fn feed_chunk(&mut self, chunk: &[u8]) -> Result<Vec<Vec<u8>>, CoolError>
Append chunk to the internal buffer and return the bytes of
every complete top-level CBOR item now in it. Drains those bytes
from the buffer; any trailing bytes that don’t yet form a
complete item stay buffered for the next call.
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Bytes currently buffered (waiting for frame completion). After the upstream stream closes, a non-zero value here indicates a truncated final frame — the server hung up mid-item.