Skip to main content

Module encoder

Module encoder 

Source
Expand description

Encoder module for ALEC compression

This module handles encoding data into compact binary messages using various encoding strategies based on context and classification.

§Overview

The encoder selects the optimal encoding strategy for each message:

  • Delta encoding: For values close to predictions
  • Repeated encoding: For unchanged values
  • Pattern encoding: For known dictionary patterns
  • Raw encoding: Fallback for unpredictable data

§Example

use alec::{Encoder, Classifier, Context, RawData};

let mut encoder = Encoder::new();
let classifier = Classifier::default();
let context = Context::new();

let data = RawData::new(22.5, 0);
let classification = classifier.classify(&data, &context);
let message = encoder.encode(&data, &classification, &context);

assert!(message.len() <= 24); // Compressed or equal to raw

Structs§

Encoder
Encoder for ALEC messages.
MessageBuilder
Builder for creating encoded messages manually