1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! `ldpc-toolbox` CLI application
//!
//! The CLI application is organized in several subcommands. The
//! supported subcommands can be seen by running `ldpc-toolbox`.
//! See the modules below for examples and more information about
//! how to use each subcommand.
use clap::Parser;
use std::error::Error;
pub mod ber;
pub mod ccsds;
pub mod ccsds_c2;
pub mod dvbs2;
pub mod encode;
pub mod mackay_neal;
pub mod nr5g;
pub mod peg;
pub mod systematic;
/// Trait to run a CLI subcommand
pub trait Run {
/// Run the CLI subcommand
fn run(&self) -> Result<(), Box<dyn Error>>;
}
/// CLI arguments.
#[derive(Debug, Parser)]
#[command(author, version, name = "ldpc-toolbox", about = "LDPC toolbox")]
pub enum Args {
/// Generates the alist of 5G NR LDPC codes.
#[command(name = "5g")]
NR5G(nr5g::Args),
/// ber subcommand
BER(ber::Args),
/// ccsds subcommand
CCSDS(ccsds::Args),
/// ccsds-c2 subcommand
#[allow(non_camel_case_types)]
CCSDS_C2(ccsds_c2::Args),
/// encode subcommand
Encode(encode::Args),
/// dvbs2 subcommand
DVBS2(dvbs2::Args),
/// mackay-neal subcommand
MackayNeal(mackay_neal::Args),
/// peg subcommand
PEG(peg::Args),
/// systematic subcommand
Systematic(systematic::Args),
}
impl Run for Args {
fn run(&self) -> Result<(), Box<dyn Error>> {
match self {
Args::BER(x) => x.run(),
Args::CCSDS(x) => x.run(),
Args::CCSDS_C2(x) => x.run(),
Args::DVBS2(x) => x.run(),
Args::Encode(x) => x.run(),
Args::MackayNeal(x) => x.run(),
Args::NR5G(x) => x.run(),
Args::PEG(x) => x.run(),
Args::Systematic(x) => x.run(),
}
}
}