7 // Decode from stream to destination struct.
8 // The actual struct pointed to by dest must match the description in fields.
9 bool pb_decode(pb_istream_t *stream, const pb_field_t fields[], void *dest_struct);
11 /* --- Helper functions ---
12 * You may want to use these from your caller or callbacks.
15 pb_istream_t pb_istream_from_buffer(uint8_t *buf, size_t bufsize);
17 bool pb_decode_varint32(pb_istream_t *stream, uint32_t *dest);
18 bool pb_decode_varint64(pb_istream_t *stream, uint64_t *dest);
20 bool pb_skip_varint(pb_istream_t *stream);
21 bool pb_skip_string(pb_istream_t *stream);
23 /* --- Field decoders ---
24 * Each decoder takes stream and field description, and a pointer to the field
25 * in the destination struct (dest = struct_addr + field->data_offset).
26 * For arrays, these functions are called repeatedly.
29 bool pb_dec_uint32(pb_istream_t *stream, const pb_field_t *field, void *dest);
30 bool pb_dec_sint32(pb_istream_t *stream, const pb_field_t *field, void *dest);
31 bool pb_dec_fixed32(pb_istream_t *stream, const pb_field_t *field, void *dest);
32 bool pb_dec_uint64(pb_istream_t *stream, const pb_field_t *field, void *dest);
33 bool pb_dec_sint64(pb_istream_t *stream, const pb_field_t *field, void *dest);
34 bool pb_dec_fixed64(pb_istream_t *stream, const pb_field_t *field, void *dest);
35 bool pb_dec_bool(pb_istream_t *stream, const pb_field_t *field, void *dest);
36 bool pb_dec_enum(pb_istream_t *stream, const pb_field_t *field, void *dest);
38 bool pb_dec_float(pb_istream_t *stream, const pb_field_t *field, void *dest);
39 bool pb_dec_double(pb_istream_t *stream, const pb_field_t *field, void *dest);
41 bool pb_dec_bytes(pb_istream_t *stream, const pb_field_t *field, void *dest);
42 bool pb_dec_string(pb_istream_t *stream, const pb_field_t *field, void *dest);
43 bool pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field, void *dest);
45 typedef bool (*pb_decoder_t)(pb_istream_t *stream, const pb_field_t *field, void *dest);
47 /* --- Function pointers to field decoders ---
48 * Order in the array must match pb_action_t LTYPE numbering.
50 const pb_decoder_t PB_DECODERS[16];