7 releases

0.2.5 Oct 3, 2023
0.2.4 Oct 3, 2023
0.2.1 Sep 16, 2023
0.1.0 Jun 3, 2023

#187 in Unix APIs

Download history 86/week @ 2023-10-29 109/week @ 2023-11-05 80/week @ 2023-11-12 116/week @ 2023-11-19 264/week @ 2023-11-26 359/week @ 2023-12-03 70/week @ 2023-12-10 76/week @ 2023-12-17 334/week @ 2023-12-24 64/week @ 2023-12-31 65/week @ 2024-01-07 63/week @ 2024-01-14 173/week @ 2024-01-21 225/week @ 2024-01-28 135/week @ 2024-02-04 309/week @ 2024-02-11

851 downloads per month

Apache-2.0

48KB
1.5K SLoC

Format-preserving parser and editor for Debian watch files

This crate supports reading, editing and writing Debian watch files, while preserving the original contents byte-for-byte.

Example:

let wf = debian_watch::WatchFile::new(None);
assert_eq!(wf.version(), debian_watch::DEFAULT_VERSION);
assert_eq!("", wf.to_string());

let wf = debian_watch::WatchFile::new(Some(4));
assert_eq!(wf.version(), 4);
assert_eq!("version=4\n", wf.to_string());

let wf: debian_watch::WatchFile = r#"version=4
opts=foo=blah https://foo.com/bar .*/v?(\d\S+)\.tar\.gz
"#.parse().unwrap();

assert_eq!(wf.version(), 4);
assert_eq!(wf.entries().collect::<Vec<_>>().len(), 1);

let entry = wf.entries().next().unwrap();
assert_eq!(entry.opts(), maplit::hashmap! {
   "foo".to_string() => "blah".to_string(),
});
assert_eq!(&entry.url(), "https://foo.com/bar");
assert_eq!(entry.matching_pattern().as_deref(), Some(".*/v?(\\d\\S+)\\.tar\\.gz"));

It also supports partial parsing (with some error nodes), which could be useful for e.g. IDEs.

Dependencies

~4.5–6.5MB
~146K SLoC