|
ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
|
A wire encoding: the ten writes, the peek, and the nine reads. More...
#include <codec.h>
Public Attributes | |
| void(* | put_uint )(pc_span *w, uint64_t v) |
| void(* | put_int )(pc_span *w, int64_t v) |
| void(* | put_bytes )(pc_span *w, const uint8_t *data, size_t len) |
| void(* | put_str )(pc_span *w, const char *s) |
| void(* | put_str_n )(pc_span *w, const char *s, size_t len) |
| void(* | put_bool )(pc_span *w, bool b) |
| void(* | put_null )(pc_span *w) |
| void(* | put_float )(pc_span *w, float f) |
| void(* | put_array )(pc_span *w, size_t count) |
| void(* | put_map )(pc_span *w, size_t count) |
| void(* | put_label )(pc_span *w, const char *name, int64_t num) |
| Emit a map key, given both spellings of it. | |
| pc_codec_type(* | peek )(pc_cspan *r) |
| bool(* | get_uint )(pc_cspan *r, uint64_t *out) |
| bool(* | get_int )(pc_cspan *r, int64_t *out) |
| bool(* | get_bytes )(pc_cspan *r, const uint8_t **out, size_t *len) |
| bool(* | get_str )(pc_cspan *r, const char **out, size_t *len) |
| bool(* | get_array )(pc_cspan *r, size_t *count) |
| bool(* | get_map )(pc_cspan *r, size_t *count) |
| bool(* | get_bool )(pc_cspan *r, bool *out) |
| bool(* | get_null )(pc_cspan *r) |
| bool(* | get_float )(pc_cspan *r, float *out) |
A wire encoding: the ten writes, the peek, and the nine reads.
Field order is the operation order every format declares and implements in. int, bool and float are keywords, so the members carry the put_ / get_ prefix that says which direction they run in.
| void(* pc_codec::put_bytes) (pc_span *w, const uint8_t *data, size_t len) |
| void(* pc_codec::put_str_n) (pc_span *w, const char *s, size_t len) |
| void(* pc_codec::put_label) (pc_span *w, const char *name, int64_t num) |
Emit a map key, given both spellings of it.
A spec often names the same field differently per encoding: RFC 8428 labels a SenML base name "bn" in JSON and -2 in CBOR. That is the encoding's business, not the caller's, so the caller hands over both and the format picks the one it is specified to write. Without this the difference leaks upward and every producer keeps one walk per encoding.
| pc_codec_type(* pc_codec::peek) (pc_cspan *r) |
| bool(* pc_codec::get_bytes) (pc_cspan *r, const uint8_t **out, size_t *len) |
| bool(* pc_codec::get_str) (pc_cspan *r, const char **out, size_t *len) |