1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! A Rust implementation of the HRX plain text archive format.
//!
//! Consult the [`google/hrx`](//github.com/google/hrx) repo for the details on the format.
//!
//! # Examples
//!
//! ```
//! # use hrx::{HrxEntryData, HrxArchive, HrxEntry, HrxError, HrxPath};
//! # use std::str::FromStr;
//! 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");
//! # Ok::<(), HrxError>(())
//! ```
//!
//! # Special thanks
//!
//! To all who support further development on [Patreon](https://patreon.com/nabijaczleweli), in particular:
//!
//!   * ThePhD
//!   * Embark Studios


extern crate linked_hash_map;
extern crate lazysort;
#[macro_use]
extern crate jetscii;

pub mod util;
pub mod parse;

mod repr;
mod error;
mod output;

pub use self::error::{ErroneousBodyPath, HrxError};
pub use self::repr::{HrxEntryData, HrxArchive, HrxEntry, HrxPath};