From 96415385ef6d2a331b10a4702f1b0af99f728c0b Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Tue, 10 Sep 2024 19:24:20 -0400 Subject: [PATCH] Convert to lib --- src/main.rs => examples/example.rs | 17 ++++++----------- src/lib.rs | 5 +++++ 2 files changed, 11 insertions(+), 11 deletions(-) rename src/main.rs => examples/example.rs (86%) create mode 100644 src/lib.rs diff --git a/src/main.rs b/examples/example.rs similarity index 86% rename from src/main.rs rename to examples/example.rs index ef3acde..bfdda96 100644 --- a/src/main.rs +++ b/examples/example.rs @@ -1,13 +1,6 @@ -// https://marknelson.us/posts/2014/10/19/data-compression-with-arithmetic-coding.html -#[allow(non_snake_case)] -mod modelA; +use sac::modelA::ModelA; -mod bit_buffer; -//mod model; -use modelA::ModelA; - -fn main() { - let data = b" +const DATA: &[u8] = 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 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 @@ -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 th Linux added, or GNU/Linux. All the so-called Linux distributions are really distributions of GNU/Linux! "; + +fn main() { type CodeValue = u32; println!( "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(); println!("compressing..."); - model.compress(&data[..], &mut compressed).unwrap(); + model.compress(&DATA[..], &mut compressed).unwrap(); println!("ModelA compressed to {} bytes", compressed.len()); println!( "Compression Ratio: {}", - data.len() as f64 / compressed.len() as f64 + DATA.len() as f64 / compressed.len() as f64 ); println!(""); diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..2d3e5ef --- /dev/null +++ b/src/lib.rs @@ -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;