pub trait MessageCodec: Default + 'static {
type Unpacked;
const PAYLOAD_BITS: u32;
const CRC_BITS: u32;
// Required methods
fn pack(&self, fields: &MessageFields) -> Option<Vec<u8>>;
fn unpack(
&self,
payload: &[u8],
ctx: &DecodeContext,
) -> Option<Self::Unpacked>;
// Provided method
fn verify_info(info: &[u8]) -> bool { ... }
}Expand description
Human-facing message payload codec (callsigns, grids, reports, free text).
Operates on the FEC-decoded information bits (PAYLOAD_BITS wide, NOT
including any CRC protecting them — callers handle the CRC layer).
Unlike FecCodec, this trait is an acceptable place for dyn when the
caller juggles heterogeneous protocols at runtime (FFI, CLI dump tools):
message unpacking is a cold path relative to DSP/FEC inner loops.
Required Associated Constants§
Sourceconst PAYLOAD_BITS: u32
const PAYLOAD_BITS: u32
Number of information bits consumed by pack / produced by unpack.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn verify_info(info: &[u8]) -> bool
fn verify_info(info: &[u8]) -> bool
Verify the integrity of post-FEC info bits. The FEC layer
invokes this when a candidate codeword satisfies parity:
returning true accepts the codeword; returning false
causes the FEC to keep iterating.
Default: accept unconditionally — appropriate for codecs whose message format carries no inline integrity field (the FEC layer has already enforced parity convergence by the time this is called).
CRC-bearing codecs override this. For example,
crate::msg::Wsjt77Message verifies the CRC-14 stored in
info bits 77..91. The associated-function (no &self) shape
keeps the verifier compatible with the function-pointer field
on FecOpts::verify_info.
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.