Expand description
C/C++ bindings for ALEC compression library
This crate provides a C-compatible FFI layer for the ALEC compression library, enabling use from C/C++ firmware and embedded systems.
§Safety
All functions in this module use raw pointers. Callers must ensure:
- Pointers are valid and non-null (unless documented otherwise)
- Buffer sizes are accurate
- Handles are not used after being freed
- Thread safety is managed by the caller
Structs§
- Alec
Decoder - Opaque decoder handle
- Alec
Encoder - Opaque encoder handle
- Alec
Encoder Config - Runtime configuration for a new ALEC encoder.
Enums§
- Alec
Result - Result codes for ALEC FFI functions
Constants§
- ALEC_
DEFAULT_ HISTORY_ SIZE - Default history size per source (validated on 99-message EM500-CO2 dataset).
- ALEC_
DEFAULT_ KEYFRAME_ INTERVAL - Default keyframe interval (messages between forced Raw32 keyframes).
- ALEC_
DEFAULT_ MAX_ MEMORY_ BYTES - Default maximum memory budget for the context (bytes).
- ALEC_
DEFAULT_ MAX_ PATTERNS - Default maximum number of patterns retained in the dictionary.
- ALEC_
DEFAULT_ NUM_ CHANNELS - Default pre-warm channel count.
0disables the pre-warm (legacy behaviour — first encode allocates per-channel state). - ALEC_
DEFAULT_ SMART_ RESYNC - Default for smart-resync via LoRaWAN downlink.
Functions§
- alec_
decode_ multi - Decode compressed data to multiple values
- alec_
decode_ multi_ fixed - Decode a fixed-channel frame produced by
alec_encode_multi_fixed. - alec_
decode_ value - Decode compressed data to a single value
- alec_
decoder_ context_ load - Restore the decoder’s context from bytes produced by
alec_decoder_context_save(oralec_decoder_export_state). - alec_
decoder_ context_ save - Save the decoder’s context to a caller-provided buffer.
- alec_
decoder_ context_ version - Get the current decoder context version
- alec_
decoder_ export_ state - Serialize the decoder’s context to a caller-provided buffer.
- alec_
decoder_ export_ state_ size - Compute the exact number of bytes
alec_decoder_export_statewould write for this decoder + sensor_type. Lets the caller allocate the right-sized buffer up front without any reallocation. - alec_
decoder_ feed_ values - Feed raw sensor values into the decoder to advance its prediction model, without an ALEC wire frame.
- alec_
decoder_ free - Free a decoder
- alec_
decoder_ gap_ detected - Check whether the most recent decode detected a sequence gap.
- alec_
decoder_ import_ state - Restore a decoder’s context from bytes produced by
alec_decoder_export_state. - alec_
decoder_ load_ context - Load decoder context from a preload file
- alec_
decoder_ new - Create a new ALEC decoder
- alec_
decoder_ new_ with_ checksum - Create a new decoder with checksum verification enabled
- alec_
decoder_ new_ with_ config - Create a new ALEC decoder with a custom configuration.
- alec_
decoder_ reset - Reset a decoder to its initial state.
- alec_
downlink_ handler - Parse a raw LoRaWAN downlink payload and apply the right action to the encoder.
- alec_
encode_ multi - Encode multiple values with adaptive per-channel compression.
- alec_
encode_ multi_ fixed - Encode a fixed-channel frame using the compact 4-byte header (Milesight EM500-CO2 wire format).
- alec_
encode_ value - Encode a single floating-point value
- alec_
encoder_ context_ load - Restore encoder state from bytes produced by
alec_encoder_context_save. - alec_
encoder_ context_ save - Save the encoder’s runtime state to a caller-provided RAM buffer.
- alec_
encoder_ context_ version - Get the current context version
- alec_
encoder_ free - Free an encoder
- alec_
encoder_ load_ context - Load encoder context from a preload file
- alec_
encoder_ new - Create a new ALEC encoder
- alec_
encoder_ new_ with_ checksum - Create a new encoder with checksum enabled
- alec_
encoder_ new_ with_ config - Create a new ALEC encoder with a custom configuration.
- alec_
encoder_ save_ context - Save encoder context to a file (for preload generation)
- alec_
force_ keyframe - Force the next encode call to emit a keyframe (Raw32 for all channels).
- alec_
result_ to_ string - Convert a result code to a human-readable string
- alec_
version - Get the ALEC library version string