Skip to main content

FecCodec

Trait FecCodec 

Source
pub trait FecCodec: Default + 'static {
    const N: usize;
    const K: usize;

    // Required methods
    fn encode(&self, info: &[u8], codeword: &mut [u8]);
    fn decode_soft(&self, llr: &[f32], opts: &FecOpts<'_>) -> Option<FecResult>;
}
Expand description

Forward-error-correction codec: maps K information bits ↔ N codeword bits.

Implementors MUST be Default-constructible so generic pipeline code can obtain an instance via P::Fec::default() without plumbing state. Stateless codecs (matrices in const / static) are the common case.

§Symbol granularity

The trait surface speaks in bits: &[u8] info / codeword, &[f32] bit-LLRs, K and N counted in bits. Non-binary codes (Q65’s QRA over GF(2⁶), JT65’s RS over GF(2⁶)) implement this surface by packing / unpacking bits ↔ symbols inside their own encode, and by using a private symbol-level decode path that lives outside decode_soft. In particular crate::q65::Q65Fec::decode_soft returns None by design — the real Q65 decode runs over GF(64) probability vectors via crate::fec::qra::Q65Codec and is invoked from crate::q65::rx::decode_at_for, not through this trait.

Counting K / N in bits keeps the cross-protocol invariant FecCodec::N ≤ N_DATA × BITS_PER_SYMBOL (pinned in tests/protocol_invariants.rs::assert_codec_consistency) meaningful for both binary (LDPC, conv) and non-binary (RS, QRA) codes.

Required Associated Constants§

Source

const N: usize

Codeword length, in bits (regardless of the underlying symbol alphabet — see “Symbol granularity” above).

Source

const K: usize

Information-bit length.

Required Methods§

Source

fn encode(&self, info: &[u8], codeword: &mut [u8])

Systematic encode: info.len() == K, codeword.len() == N. The first K bits of codeword must equal info (systematic form). Non-binary codes pack bits into their native symbols internally.

Source

fn decode_soft(&self, llr: &[f32], opts: &FecOpts<'_>) -> Option<FecResult>

Soft-decision decode from log-likelihood ratios.

llr.len() == N. On success returns the K information bits plus decoder statistics. On failure returns None.

Non-binary codes whose natural decode operates on symbol-level probability vectors (Q65) MAY return None unconditionally and expose their real decode through a protocol-specific entry point.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl FecCodec for ConvFano

Source§

const N: usize = 162

Source§

const K: usize = 50

Source§

impl FecCodec for ConvFano232

Source§

const N: usize = 206

Source§

const K: usize = 72

Source§

impl FecCodec for Ldpc128_90

Source§

const N: usize = LDPC_N

Source§

const K: usize = LDPC_K

Source§

impl FecCodec for Ldpc174_91

Source§

const N: usize = LDPC_N

Source§

const K: usize = LDPC_K

Source§

impl FecCodec for Ldpc240_101

Source§

const N: usize = LDPC_N

Source§

const K: usize = LDPC_K

Source§

impl FecCodec for Q65Fec

Source§

impl FecCodec for Rs63_12