serbzip_core/lib.rs
1//! A lightweight framework for transcoding text from one lexical form to another.
2//!
3//! The apparatus that performs this trancoding is called a **codec**. It is described by the
4//! [`codecs::Codec`] trait. A prominent example of such a codec is **Balkanoid** —
5//! a quasi-lossless Balkanoidal meta-lingual compressor.
6//!
7//! This crate provides mechanisms for creating codecs, as well as one or more useful
8//! codec implementations.
9//!
10//! # Examples
11//! Compression and expansion of text using the [`codecs::balkanoid::Balkanoid`]
12//! codec:
13//! ```
14//! use std::fs::File;
15//! use std::io;
16//! use std::io::BufReader;
17//! use serbzip_core::codecs::balkanoid::{Balkanoid, Dict};
18//! use serbzip_core::codecs::Codec;
19//!
20//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
21//! // this codec needs a dictionary to work from
22//! let mut dict_reader = BufReader::new(File::open("../dict.blk")?);
23//! let dict = Dict::read_from_binary_image(&mut dict_reader)?;
24//! let codec = Balkanoid::new(&dict);
25//!
26//! // compress a line and check the output
27//! let input_line = "Ah, distinctly I remember it was in the bleak December";
28//! let compressed_line = codec.compress_line(input_line);
29//! assert_eq!(compressed_line, "H, dstnctly I rmmbr t ws n th blk Dcmbr");
30//!
31//! // expand the line; check that it matches the original
32//! let expanded_line = codec.expand_line(&compressed_line)?;
33//! assert_eq!(input_line, expanded_line);
34//!
35//! // codecs also have helper methods for parsing I/O streams
36//! let mut input_reader = BufReader::new(File::open("../test_data/antigonish.txt")?);
37//! let mut output_writer = io::Cursor::new(Vec::new());
38//! codec.compress(&mut input_reader, &mut output_writer)?;
39//! let compressed_document = String::from_utf8(output_writer.into_inner())?;
40//! assert_ne!("", compressed_document);
41//! # Ok(())
42//! # }
43//! ```
44
45pub mod codecs;
46pub mod succinct;
47pub mod transcoder;
48
49#[doc = include_str!("../README.md")]
50#[cfg(doc)]
51fn readme() {}