fountain_engine 2.0.1

Core algorithms for fountain code encoding and decoding
Documentation
// Copyright (c) 2025 Shenghao Yang. All rights reserved.
// Licensed under AGPL-3.0 or commercial license. See LICENSE for details.

use super::{HDPC, LDPC};
use crate::types::{CodeParams, CodeType, DecodingConfig, DegreeSetFn};

pub type PrecodePair = (Option<Box<dyn HDPC>>, Option<Box<dyn LDPC>>);

/// Trait for code configuration
pub trait CodeScheme {
    /// Get code parameters
    fn get_params(&self) -> CodeParams;

    /// Get code type (systematic or ordinary)
    fn code_type(&self) -> CodeType;

    /// Create degree set generator
    fn create_degree_set_fn(&self) -> DegreeSetFn;

    /// Create precode components
    fn create_precode(&self) -> PrecodePair;

    /// Maximum number of inactivations
    #[deprecated(since = "1.1.0", note = "use decoding_config instead")]
    fn max_inactive_num(&self) -> usize {
        self.get_params().h + self.get_params().b
    }

    /// Decoding configuration
    fn decoding_config(&self) -> DecodingConfig {
        DecodingConfig::default().with_max_inact_num(self.get_params().num_inactive())
    }
}