ben/
lib.rs

1//! This crate provides several command line tools and functions for converting
2//! ensembles of districting plans contained in a JSONL file with lines of the
3//! form
4//!
5//! ```text
6//! {"assignment": <assignment>, "sample": <sample>}
7//! ```
8//!
9//! into binary ensembles (BEN) and extremely compressed binary ensembles
10//! (XBEN). It also provides several tools for working with these files
11//! including several tools for relabeling the ensembles to improve
12//! compression ratios.
13//!
14//! The main CLI tools provided by this crate are:
15//!
16//! - `ben`: A tool for converting JSONL files into BEN files.
17//!    and for converting between BEN and XBEN files.
18//! - `reben`: A tool for relabeling BEN files to improve compression ratios.
19//!
20
21pub mod decode;
22pub mod encode;
23pub mod utils;
24
25#[macro_export]
26macro_rules! log {
27    ($($arg:tt)*) => {{
28        if let Ok(log_level) = std::env::var("RUST_LOG") {
29            if log_level.to_lowercase() == "trace" {
30                eprint!($($arg)*);
31            }
32        }
33    }}
34}
35
36#[macro_export]
37macro_rules! logln {
38    ($($arg:tt)*) => {{
39        if let Ok(log_level) = std::env::var("RUST_LOG") {
40            if log_level.to_lowercase() == "trace" {
41                eprintln!($($arg)*);
42            }
43        }
44    }}
45}
46
47#[derive(Debug, Clone, Copy, PartialEq)]
48pub enum BenVariant {
49    Standard,
50    MkvChain,
51}