xref: /freebsd/contrib/libcbor/doc/source/api.rst (revision 5d3e7166)
1API
2=======
3
4The data API is centered around :type:`cbor_item_t`, a generic handle for any CBOR item. There are functions to
5
6 - create items,
7 - set items' data,
8 - parse serialized data into items,
9 - manage, move, and links item together.
10
11The single most important thing to keep in mind is: :type:`cbor_item_t` **is an opaque type and should only be manipulated using the appropriate functions!** Think of it as an object.
12
13The *libcbor* API closely follows the semantics outlined by `CBOR standard <https://tools.ietf.org/html/rfc7049>`_. This part of the documentation provides a short overview of the CBOR constructs, as well as a general introduction to the *libcbor* API. Remaining reference can be found in the following files structured by data types.
14
15The API is designed to allow both very tight control & flexibility and general convenience with sane defaults. [#]_ For example, client with very specific requirements (constrained environment, custom application protocol built on top of CBOR, etc.) may choose to take full control (and responsibility) of memory and data structures management by interacting directly with the decoder. Other clients might want to take control of specific aspects (streamed collections, hash maps storage), but leave other responsibilities to *libcbor*. More general clients might prefer to be abstracted away from all aforementioned details and only be presented complete data structures.
16
17
18*libcbor* provides
19 - stateless encoders and decoders
20 - encoding and decoding *drivers*, routines that coordinate encoding and decoding of complex structures
21 - data structures to represent and transform CBOR structures
22 - routines for building and manipulating these structures
23 - utilities for inspection and debugging
24
25.. toctree::
26
27   api/item_types
28   api/item_reference_counting
29   api/decoding
30   api/encoding
31   api/streaming_decoding
32   api/streaming_encoding
33   api/type_0_1
34   api/type_2
35   api/type_3
36   api/type_4
37   api/type_5
38   api/type_6
39   api/type_7
40
41.. [#] http://softwareengineering.vazexqi.com/files/pattern.html
42