datasus-dbc 0.1.1

Decompress DATASUS's *.dbc files into *.dbf files.
Documentation
  • Coverage
  • 88.89%
    8 out of 9 items documented1 out of 1 items with examples
  • Size
  • Source code size: 32.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.42 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • mymatsubara/datasus-dbc
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mymatsubara

datasus-dbc

crates.io docs.rs

Decompress *.dbc files usually found in Brazil's DATASUS ftp server into *.dbf files.

The underlying decompression algorithm used in *.dbc files is the implode algorithm from the PKWARE Data Compression Library. This library uses Aaron Griffith's rust implementation of the implode algorithm. Also, this library is heavily inspired by Daniela Petruzalek's pysus. I want to thank both of them, without their work this library would not be possible.

Examples

To decompress a *.dbc file into a *.dbf use decompress:

datasus_dbc::decompress("input.dbc", "output.dbf");

If you want more control over how the *.dbc file is read, you can pass a File or other type which implements Read to into_dbf_reader to get a reader of the decompressed content.

use std::io::Read;

let dbc_file = std::fs::File::open("input.dbc").unwrap();
let mut dbf_reader = datasus_dbc::into_dbf_reader(dbc_file).unwrap();
let mut buf: Vec<u8> = Default::default();
dbf_reader.read_to_end(&mut buf).unwrap();
println!("{:?}", &buf[0..20]);

Found a bug?

Feel free to create an issue here if you found a bug or if you want a new feature!