Skip to main content

BlockCode

Trait BlockCode 

Source
pub trait BlockCode {
    // Required methods
    fn k(&self) -> usize;
    fn n(&self) -> usize;
    fn encode_block(&self, info: &[u8]) -> Result<Vec<u8>>;
    fn decode_block(&self, llr: &[f64]) -> Result<Vec<u8>>;

    // Provided methods
    fn encode_block_into(&self, info: &[u8], out: &mut [u8]) -> Result<()> { ... }
    fn decode_block_into(&self, llr: &[f64], out: &mut [u8]) -> Result<()> { ... }
    fn code_rate(&self) -> f64 { ... }
    fn encode_stream(&self, info: &[u8]) -> Result<Vec<u8>> { ... }
    fn decode_stream(&self, llr: &[f64]) -> Result<Vec<u8>> { ... }
}
Expand description

A code of $k$ information bits and $n$ coded bits per block.

Required Methods§

Source

fn k(&self) -> usize

Information bits per block.

Source

fn n(&self) -> usize

Coded bits per block.

Source

fn encode_block(&self, info: &[u8]) -> Result<Vec<u8>>

Encode one block of $k$ bits.

§Errors

Error::Shape if info does not have $k$ bits.

Source

fn decode_block(&self, llr: &[f64]) -> Result<Vec<u8>>

Decode one block of $n$ LLRs into $k$ bits.

§Errors

Error::Shape if llr does not have $n$ values.

Provided Methods§

Source

fn encode_block_into(&self, info: &[u8], out: &mut [u8]) -> Result<()>

Encode one block of $k$ bits into the $n$ values of out (ADR 0011: the default copies BlockCode::encode_block; a code overrides it when a profile shows the copy).

§Errors

Error::Shape if info does not have $k$ bits or out $n$ values.

Source

fn decode_block_into(&self, llr: &[f64], out: &mut [u8]) -> Result<()>

Decode one block of $n$ LLRs into the $k$ values of out (as BlockCode::encode_block_into).

§Errors

Error::Shape if llr does not have $n$ values or out $k$ values.

Source

fn code_rate(&self) -> f64

Code rate $k/n$.

Source

fn encode_stream(&self, info: &[u8]) -> Result<Vec<u8>>

Encode whole blocks.

§Errors

Error::Shape if the number of bits is not a multiple of $k$.

Source

fn decode_stream(&self, llr: &[f64]) -> Result<Vec<u8>>

Decode whole blocks.

§Errors

Error::Shape if the number of LLRs is not a multiple of $n$.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§