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§
Required Methods§
Sourcefn encode(&self, info: &[u8], codeword: &mut [u8])
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.
Sourcefn decode_soft(&self, llr: &[f32], opts: &FecOpts<'_>) -> Option<FecResult>
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".