2 releases

Uses old Rust 2015

0.1.1 Nov 9, 2021
0.1.0 May 26, 2019

#1437 in Encoding

MIT license

38KB
442 lines

hrx.rs TravisCI Build Status AppVeyorCI Build Status Licence Crates.io version

A Rust implementation of the HRX plain text archive format.

Documentation

Special thanks

To all who support further development on Patreon, in particular:

  • ThePhD
  • Embark Studios
  • Jasper Bekkers

lib.rs:

A Rust implementation of the HRX plain text archive format.

Consult the google/hrx repo for the details on the format.

Examples

let input_text = "<===> input.scss
ul {
  li {
    list-style: none;
  }
}

<===>
Generated files
<===> out/

<===> out/input.css
ul li {
  list-style: none;
}
";

let mut archive = HrxArchive::from_str(input_text)?;

assert_eq!(archive.comment, None);
assert_eq!(archive.entries,
           [(HrxPath::from_str("input.scss")?,
             HrxEntry {
                comment: None,
                data: HrxEntryData::File {
                    body: Some("ul {\n  li {\n    list-style: none;\n  }\n}\n".to_string()),
                },
             }),
            (HrxPath::from_str("out")?,
             HrxEntry {
                comment: Some("Generated files".to_string()),
                data: HrxEntryData::Directory,
             }),
            (HrxPath::from_str("out/input.css")?,
             HrxEntry {
                comment: None,
                data: HrxEntryData::File {
                    body: Some("ul li {\n  list-style: none;\n}\n".to_string()),
                },
             })].iter().cloned().collect());

archive.entries.remove(&HrxPath::from_str("out")?);
archive.comment = Some("Snapshot of commit 264a050c".to_string());

let mut out = vec![];
archive.serialise(&mut out).unwrap();

assert_eq!(String::from_utf8(out).unwrap(), "<===> input.scss
ul {
  li {
    list-style: none;
  }
}

<===> out/input.css
ul li {
  list-style: none;
}

<===>
Snapshot of commit 264a050c");

Special thanks

To all who support further development on Patreon, in particular:

  • ThePhD
  • Embark Studios
  • Jasper Bekkers

Dependencies

~0.6–1.7MB
~31K SLoC