[−][src]Crate hrx
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
Modules
parse | Individual parsing primitives. |
util | Module containing various utility functions. |
Structs
HrxArchive | A Human-Readable Archive, consisting of an optional comment and some entries, all separated by the boundary. |
HrxEntry | A single entry in the archive, consisting of an optional comment and some data. |
HrxPath | Verified-valid path to an entry in the archive. |
Enums
ErroneousBodyPath | A path to a |
HrxEntryData | Some variant of an entry's contained data. |
HrxError | Generic error type, encompassing more precise errors. |