Skip to main content

Crate alec_ffi

Crate alec_ffi 

Source
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§

AlecDecoder
Opaque decoder handle
AlecEncoder
Opaque encoder handle
AlecEncoderConfig
Runtime configuration for a new ALEC encoder.

Enums§

AlecResult
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. 0 disables 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 (or alec_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_state would 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