Convert to lib

This commit is contained in:
Lucas Schumacher 2024-09-10 19:24:20 -04:00
parent 34d0f0bafa
commit 96415385ef
2 changed files with 11 additions and 11 deletions

View File

@ -1,13 +1,6 @@
// https://marknelson.us/posts/2014/10/19/data-compression-with-arithmetic-coding.html use sac::modelA::ModelA;
#[allow(non_snake_case)]
mod modelA;
mod bit_buffer; const DATA: &[u8] = b"
//mod model;
use modelA::ModelA;
fn main() {
let data = b"
I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've re I'd just like to interject for a moment. What you're refering to as Linux, is in fact, GNU/Linux, or as I've re
aken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free compo aken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free compo
a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components com a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components com
@ -23,6 +16,8 @@ an essential part of an operating system, but useless by itself; it can only fun
ating system. Linux is normally used in combination with the GNU operating system: the whole system is basicall ating system. Linux is normally used in combination with the GNU operating system: the whole system is basicall
th Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux! th Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux!
"; ";
fn main() {
type CodeValue = u32; type CodeValue = u32;
println!( println!(
"Using model: ModelA<{}>", "Using model: ModelA<{}>",
@ -34,11 +29,11 @@ th Linux added, or GNU/Linux. All the so-called Linux distributions are really d
let mut compressed = Vec::new(); let mut compressed = Vec::new();
println!("compressing..."); println!("compressing...");
model.compress(&data[..], &mut compressed).unwrap(); model.compress(&DATA[..], &mut compressed).unwrap();
println!("ModelA compressed to {} bytes", compressed.len()); println!("ModelA compressed to {} bytes", compressed.len());
println!( println!(
"Compression Ratio: {}", "Compression Ratio: {}",
data.len() as f64 / compressed.len() as f64 DATA.len() as f64 / compressed.len() as f64
); );
println!(""); println!("");

5
src/lib.rs Normal file
View File

@ -0,0 +1,5 @@
// https://marknelson.us/posts/2014/10/19/data-compression-with-arithmetic-coding.html
#[allow(non_snake_case)]
pub mod modelA;
mod bit_buffer;