# binhex
This crate provides a rust implementation for reading _BinHex 4_ files.
Introduced in 1995, the _BinHex_ 4 format gained popularity in the early 90s among
Macintosh users, as it combined _Finder_ info of a file with its data and resource
forks and wrapped everything up in a format that could easily and safely be
shared via E-Mail and users on message boards.
As BinHex files are just ASCII text files, they can be hard to identify. If
present, the `hqx` file extension is a good indicator, otherwise the whole file
has to be searched progressively for the header indicating the start of encoded data.
The crate should be used by creating an [`Archive`] struct from an existing [`io::Read`],
like a [`fs::File`] or [`io::Cursor`].
```rust
use std::{io,fs};
use std::io::Read;
use fourcc_rs::fourcc;
// Open BinHex file
let mut archive = binhex::Archive::open("sample-file.hqx").unwrap();
// Read whole file and verify checksums
assert!(archive.verify().is_ok());
// Make sure we got the correct file
assert_eq!(archive.name(), "binhex.test.sit");
assert_eq!(archive.file_code(), fourcc!("SITD"));
// Read the data fork
let mut buffer = vec![0u8; archive.data_len()];
let mut data_fork_reader = archive.data_fork().unwrap();
data_fork_reader.read_exact(&mut buffer).unwrap();
// Read the resource fork
let mut buffer = vec![0u8; archive.resource_len() as usize];
let mut rsrc_fork_reader = archive.data_fork().unwrap();
rsrc_fork_reader.read_exact(&mut buffer).unwrap();
```