Ada 2022 · RFC 8949 · experimental

Streaming CBOR syntax for Ada

Flyology CBOR parses arbitrary byte chunks into provisional syntax events. Its writers stage one complete document before publication. The bounded parser and writer allocate no heap storage.

arbitrary CBOR chunksexact byte offsets
A2 64 6E 616D 65 63 41 64 61 61 6E19 03 E8
parser validates across chunks · parser retains no input reference
Map_BeginText_String_Fragment Unsigned_ValueMap_End exact rangesraw float bits
events are provisionalDocument_Complete → caller accepts candidate

Separate unsigned 42 API example

Parse unsigned 42
   --  The chunk is complete. Drain batches provisional events into the
   --  caller-owned event array and reports complete-document acceptance.
   Parsing.Drain
     (Self         => Parser,
      Input        => Input,
      End_Of_Input => True,
      Events       => Events,
      Result       => Parse_Result);
Write unsigned 42
   --  Finish_Document makes the staged complete value eligible. Copy_Output
   --  never exposes an incomplete prefix as successful output.
   Writing.Begin_Document (Writer, Diagnostic);
   Writing.Put_Unsigned (Writer, 42, Diagnostic);
   Writing.Finish_Document (Writer, Diagnostic);
   Writing.Copy_Output (Writer, Output, Produced, Diagnostic);
InputArbitrary-bound byte arrays and chunk schedules.
StorageCaller-selected syntax depth; bounded writers also select output capacity.
ValuesRaw integers, tags, simple values, and float bits.
BoundaryNo schema model or traversal; no Wire, OS, or C dependency.
Writer

Publish the whole document

The bounded and allocating facades own unpublished staging. Finish_Document validates the balanced CBOR item and is the only publication request. A failure or abort never makes a staged prefix eligible as output.

  1. Initialize
  2. Begin_Document
  3. Stage bytes
  4. Finish_Document

Abort or failure ends unpublished staging without publication.

Public layers

Choose storage explicitly

Flyology CBOR owns byte syntax and diagnostics. Your application owns transport buffers, the event array, logical interpretation, and the decision to accept a decoded candidate.

Streaming parser

Use Step or Drain and process borrowed fragments against the exact unchanged input passed to the producing call.

Parse CBOR →

Bounded writer

Own a fixed staging buffer with observable unpublished length and Completed-only output.

Write CBOR →

Raw values

Preserve CBOR integer arguments, tag numbers, simple codes, and float widths before interpretation.

Inspect values →