Skip to main content

DecodingStrategy

Trait DecodingStrategy 

Source
pub trait DecodingStrategy:
    Send
    + Sync
    + 'static {
    type Code: Clone + Debug + Send + Sync;

    // Required methods
    fn from_intensities(intensities: &[f64], thresholds: &[f64]) -> Self::Code;
    fn distance(code: &Self::Code, target: u64) -> u32;
    fn decode(
        code: &Self::Code,
        decoder: &(impl TagDecoder + ?Sized),
        max_error: u32,
    ) -> Option<(u32, u32, u8)>;
    fn to_debug_bits(code: &Self::Code) -> u64;
}
Expand description

Trait abstracting the decoding strategy (Hard vs Soft).

Required Associated Types§

Source

type Code: Clone + Debug + Send + Sync

The type of code extracted from the image (e.g., u64 bits or Vec<i16> LLRs).

Required Methods§

Source

fn from_intensities(intensities: &[f64], thresholds: &[f64]) -> Self::Code

Convert intensities and thresholds into a code.

Source

fn distance(code: &Self::Code, target: u64) -> u32

Compute the “distance” between the extracted code and a dictionary target.

For Hard decoding, this is Hamming distance. For Soft decoding, this is the accumulated penalty of mismatching LLRs.

Source

fn decode( code: &Self::Code, decoder: &(impl TagDecoder + ?Sized), max_error: u32, ) -> Option<(u32, u32, u8)>

Decode the code into an ID using the provided decoder.

Source

fn to_debug_bits(code: &Self::Code) -> u64

Convert the code to a debug bitstream (u64).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§