xref: /src/contrib/libcbor/doc/source/api/streaming_decoding.rst (revision 5d3e7166f6a0187fa3f8831b16a06bd9955c21ff)
1058aa793SEd MasteStreaming Decoding
25b2defbdSEd Maste=============================
35b2defbdSEd Maste
4058aa793SEd Maste*libcbor* exposes a stateless decoder that reads a stream of input bytes from a buffer and invokes user-provided callbacks as it decodes the input:
55b2defbdSEd Maste
65b2defbdSEd Maste.. doxygenfunction:: cbor_stream_decode
75b2defbdSEd Maste
8058aa793SEd MasteFor example, when :func:`cbor_stream_decode` encounters a 1B unsigned integer, it will invoke the function pointer stored in ``cbor_callbacks.uint8``.
9058aa793SEd MasteComplete usage example: `examples/streaming_parser.c <https://github.com/PJK/libcbor/blob/master/examples/streaming_parser.c>`_
105b2defbdSEd Maste
115b2defbdSEd MasteThe callbacks are defined by
125b2defbdSEd Maste
135b2defbdSEd Maste.. doxygenstruct:: cbor_callbacks
145b2defbdSEd Maste    :members:
155b2defbdSEd Maste
165b2defbdSEd MasteWhen building custom sets of callbacks, feel free to start from
175b2defbdSEd Maste
185b2defbdSEd Maste.. doxygenvariable:: cbor_empty_callbacks
195b2defbdSEd Maste
205b2defbdSEd Maste
215b2defbdSEd MasteCallback types definition
225b2defbdSEd Maste~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235b2defbdSEd Maste
245b2defbdSEd Maste
255b2defbdSEd Maste.. doxygentypedef:: cbor_int8_callback
265b2defbdSEd Maste.. doxygentypedef:: cbor_int16_callback
275b2defbdSEd Maste.. doxygentypedef:: cbor_int32_callback
285b2defbdSEd Maste.. doxygentypedef:: cbor_int64_callback
295b2defbdSEd Maste.. doxygentypedef:: cbor_simple_callback
305b2defbdSEd Maste.. doxygentypedef:: cbor_string_callback
315b2defbdSEd Maste.. doxygentypedef:: cbor_collection_callback
325b2defbdSEd Maste.. doxygentypedef:: cbor_float_callback
335b2defbdSEd Maste.. doxygentypedef:: cbor_double_callback
345b2defbdSEd Maste.. doxygentypedef:: cbor_bool_callback
35