File syn_protobuf.h¶
FileList > src > syntropic > util > syn_protobuf.h
Go to the source code of this file
Zero-Allocation Protocol Buffers Serializer & Deserializer. More...
#include "syntropic/common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_PB_Decoder |
| struct | SYN_PB_Encoder |
| struct | SYN_PB_Tag |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_pb_decode_bytes (SYN_PB_Decoder * dec, const uint8_t ** bytes, size_t * len) Decode a length-delimited byte array field. |
| SYN_Status | syn_pb_decode_fixed32 (SYN_PB_Decoder * dec, uint32_t * value) Decode a fixed 32-bit integer field value. |
| SYN_Status | syn_pb_decode_tag (SYN_PB_Decoder * dec, SYN_PB_Tag * tag) Decode the next field tag and wire type. |
| SYN_Status | syn_pb_decode_varint (SYN_PB_Decoder * dec, uint64_t * value) Decode a raw varint value. |
| SYN_Status | syn_pb_decoder_init (SYN_PB_Decoder * dec, const uint8_t * buf, size_t size) Initialize a Protobuf decoder instance. |
| SYN_Status | syn_pb_encode_bool (SYN_PB_Encoder * enc, uint32_t field_number, bool value) Encode a boolean field. |
| SYN_Status | syn_pb_encode_bytes (SYN_PB_Encoder * enc, uint32_t field_number, const uint8_t * bytes, size_t len) Encode a raw byte array field. |
| SYN_Status | syn_pb_encode_fixed32 (SYN_PB_Encoder * enc, uint32_t field_number, uint32_t value) Encode a fixed 32-bit integer field. |
| SYN_Status | syn_pb_encode_int32 (SYN_PB_Encoder * enc, uint32_t field_number, int32_t value) Encode a signed 32-bit integer field. |
| SYN_Status | syn_pb_encode_string (SYN_PB_Encoder * enc, uint32_t field_number, const char * str) Encode a UTF-8 string field. |
| SYN_Status | syn_pb_encode_tag (SYN_PB_Encoder * enc, uint32_t field_number, uint8_t wire_type) Encode field tag and wire type. |
| SYN_Status | syn_pb_encode_uint32 (SYN_PB_Encoder * enc, uint32_t field_number, uint32_t value) Encode an unsigned 32-bit integer field. |
| SYN_Status | syn_pb_encode_varint (SYN_PB_Encoder * enc, uint64_t value) Encode a raw varint value. |
| SYN_Status | syn_pb_encoder_init (SYN_PB_Encoder * enc, uint8_t * buf, size_t capacity) Initialize a Protobuf encoder instance. |
| SYN_Status | syn_pb_skip_field (SYN_PB_Decoder * dec, uint8_t wire_type) Skip unknown field based on wire type. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_PB_WIRE_FIXED32 5U |
| define | SYN_PB_WIRE_FIXED64 1U |
| define | SYN_PB_WIRE_LENGTH_DELIMITED 2U |
| define | SYN_PB_WIRE_VARINT 0U |
Detailed Description¶
Provides varint (LEB128), fixed32/64, length-delimited string/bytes encoding and decoding for compact binary serialization on microcontrollers.
Public Functions Documentation¶
function syn_pb_decode_bytes¶
Decode a length-delimited byte array field.
Parameters:
decPointer to decoder instance.bytesOutput byte array pointer pointer.lenOutput byte array length pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on EOF.
function syn_pb_decode_fixed32¶
Decode a fixed 32-bit integer field value.
Parameters:
decPointer to decoder instance.valueOutput 32-bit value pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on EOF.
function syn_pb_decode_tag¶
Decode the next field tag and wire type.
Parameters:
decPointer to decoder instance.tagOutput tag structure pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on EOF.
function syn_pb_decode_varint¶
Decode a raw varint value.
Parameters:
decPointer to decoder instance.valueOutput 64-bit value pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on EOF.
function syn_pb_decoder_init¶
Initialize a Protobuf decoder instance.
Parameters:
decPointer to decoder instance.bufInput byte buffer pointer.sizeInput byte buffer length.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if NULL.
function syn_pb_encode_bool¶
Encode a boolean field.
Parameters:
encPointer to encoder instance.field_numberField tag number.valueBoolean value.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encode_bytes¶
Encode a raw byte array field.
SYN_Status syn_pb_encode_bytes (
SYN_PB_Encoder * enc,
uint32_t field_number,
const uint8_t * bytes,
size_t len
)
Parameters:
encPointer to encoder instance.field_numberField tag number.bytesPointer to input byte array.lenLength of byte array.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encode_fixed32¶
Encode a fixed 32-bit integer field.
Parameters:
encPointer to encoder instance.field_numberField tag number.valueFixed 32-bit integer value.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encode_int32¶
Encode a signed 32-bit integer field.
Parameters:
encPointer to encoder instance.field_numberField tag number.valueSigned 32-bit integer value.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encode_string¶
Encode a UTF-8 string field.
Parameters:
encPointer to encoder instance.field_numberField tag number.strNull-terminated string pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encode_tag¶
Encode field tag and wire type.
Parameters:
encPointer to encoder instance.field_numberField tag number.wire_typeProtobuf wire type (0, 1, 2, 5).
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encode_uint32¶
Encode an unsigned 32-bit integer field.
Parameters:
encPointer to encoder instance.field_numberField tag number.valueUnsigned 32-bit integer value.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encode_varint¶
Encode a raw varint value.
Parameters:
encPointer to encoder instance.value64-bit value to encode.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on overflow.
function syn_pb_encoder_init¶
Initialize a Protobuf encoder instance.
Parameters:
encPointer to encoder instance.bufOutput byte buffer.capacityMaximum buffer size in bytes.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if NULL or zero.
function syn_pb_skip_field¶
Skip unknown field based on wire type.
Parameters:
decPointer to decoder instance.wire_typeWire type of field to skip.
Returns:
SYN_OK on success, SYN_INVALID_PARAM or SYN_ERROR on failure.
Macro Definition Documentation¶
define SYN_PB_WIRE_FIXED32¶
fixed32, sfixed32, float
define SYN_PB_WIRE_FIXED64¶
fixed64, sfixed64, double
define SYN_PB_WIRE_LENGTH_DELIMITED¶
string, bytes, embedded messages
define SYN_PB_WIRE_VARINT¶
Protobuf Wire Types int32, int64, uint32, uint64, bool, enum
The documentation for this class was generated from the following file src/syntropic/util/syn_protobuf.h