datasus_dbc/lib.rs
1//! Decompress `*.dbc` files usually found in Brazil's DATASUS [ftp server] into `*.dbf` files.
2//!
3//! The underlying decompression algorithm used in `*.dbc` files is the *implode* algorithm from the PKWARE Data Compression Library.
4//! This library uses *Aaron Griffith*'s [rust implementation] of the *implode* algorithm. Also,
5//! this library is heavily inspired by *Daniela Petruzalek*'s [pysus]. I want to thank both of them, without their work this library
6//! would not be possible.
7//!
8//! [ftp server]: ftp://ftp.datasus.gov.br/dissemin/publicos
9//! [rust implementation]: https://crates.io/crates/explode
10//! [pysus]: https://github.com/danicat/pysus
11//!
12//! # Examples
13//!
14//! To decompress a `*.dbc` file into a `*.dbf` use [`decompress`](fn.decompress.html):
15//! ```no_run
16//! datasus_dbc::decompress("input.dbc", "output.dbf");
17//! ```
18//!
19//! ---
20//!
21//! If you want more control over how the `*.dbc` file is read,
22//! you can pass a [`File`][File] or other type which implements [`Read`][Read] to [`into_dbf_reader`](fn.into_dbf_reader.html)
23//! to get a reader of the decompressed content.
24//! ```no_run
25//! use std::io::Read;
26//!
27//! let dbc_file = std::fs::File::open("input.dbc").unwrap();
28//! let mut dbf_reader = datasus_dbc::into_dbf_reader(dbc_file).unwrap();
29//! let mut buf: Vec<u8> = Default::default();
30//! dbf_reader.read_to_end(&mut buf).unwrap();
31//! println!("{:?}", &buf[0..20]);
32//! ```
33//!
34//! [Read]: https://doc.rust-lang.org/std/io/trait.Read.html
35//! [File]: https://doc.rust-lang.org/std/io/struct.File.html
36//!
37
38mod decompress;
39mod error;
40
41pub use decompress::{decompress, into_dbf_reader};
42pub use error::{Error, Result};