Convert to lib
This commit is contained in:
45
examples/example.rs
Normal file
45
examples/example.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use sac::modelA::ModelA;
|
||||
|
||||
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
|
||||
a full OS as defined by POSIX.
|
||||
|
||||
Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculia
|
||||
f events, the version of GNU which is widely used today is often called Linux, and many of its users are not aw
|
||||
it is basically the GNU system, developed by the GNU Project.
|
||||
|
||||
There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is
|
||||
el: the program in the system that allocates the machine's resources to the other programs that you run. The ke
|
||||
an essential part of an operating system, but useless by itself; it can only function in the context of a compl
|
||||
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<{}>",
|
||||
std::any::type_name::<CodeValue>()
|
||||
);
|
||||
let model: ModelA<CodeValue> = ModelA::default();
|
||||
model.print_metrics();
|
||||
println!("");
|
||||
|
||||
let mut compressed = Vec::new();
|
||||
println!("compressing...");
|
||||
model.compress(&DATA[..], &mut compressed).unwrap();
|
||||
println!("ModelA compressed to {} bytes", compressed.len());
|
||||
println!(
|
||||
"Compression Ratio: {}",
|
||||
DATA.len() as f64 / compressed.len() as f64
|
||||
);
|
||||
println!("");
|
||||
|
||||
println!("decompressing...");
|
||||
let mut decompressed = Vec::new();
|
||||
let model: ModelA<CodeValue> = ModelA::default();
|
||||
model.decompress(&compressed, &mut decompressed).unwrap();
|
||||
println!("{}", String::from_utf8_lossy(&decompressed));
|
||||
}
|
||||
Reference in New Issue
Block a user