xref: /netbsd-src/external/mit/libcbor/dist/doc/source/api.rst (revision 5dd36a3bc8bf2a9dec29ceb6349550414570c447)
1*5dd36a3bSchristosAPI
2*5dd36a3bSchristos=======
3*5dd36a3bSchristos
4*5dd36a3bSchristosThe data API is centered around :type:`cbor_item_t`, a generic handle for any CBOR item. There are functions to
5*5dd36a3bSchristos
6*5dd36a3bSchristos - create items,
7*5dd36a3bSchristos - set items' data,
8*5dd36a3bSchristos - parse serialized data into items,
9*5dd36a3bSchristos - manage, move, and links item together.
10*5dd36a3bSchristos
11*5dd36a3bSchristosThe 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*5dd36a3bSchristos
13*5dd36a3bSchristosThe *libcbor* API closely follows the semantics outlined by `CBOR standard <http://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*5dd36a3bSchristos
15*5dd36a3bSchristosThe 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*5dd36a3bSchristos
17*5dd36a3bSchristos
18*5dd36a3bSchristos*libcbor* provides
19*5dd36a3bSchristos - stateless encoders and decoders
20*5dd36a3bSchristos - encoding and decoding *drivers*, routines that coordinate encoding and decoding of complex structures
21*5dd36a3bSchristos - data structures to represent and transform CBOR structures
22*5dd36a3bSchristos - routines for building and manipulating these structures
23*5dd36a3bSchristos - utilities for inspection and debugging
24*5dd36a3bSchristos
25*5dd36a3bSchristos.. toctree::
26*5dd36a3bSchristos
27*5dd36a3bSchristos   api/item_types
28*5dd36a3bSchristos   api/item_reference_counting
29*5dd36a3bSchristos   api/decoding
30*5dd36a3bSchristos   api/encoding
31*5dd36a3bSchristos   api/type_0_1
32*5dd36a3bSchristos   api/type_2
33*5dd36a3bSchristos   api/type_3
34*5dd36a3bSchristos   api/type_4
35*5dd36a3bSchristos   api/type_5
36*5dd36a3bSchristos   api/type_6
37*5dd36a3bSchristos   api/type_7
38*5dd36a3bSchristos
39*5dd36a3bSchristos.. [#] http://softwareengineering.vazexqi.com/files/pattern.html
40