9 releases

0.2.7 Mar 9, 2024
0.2.6 Mar 9, 2024
0.2.5 Oct 3, 2023
0.2.1 Sep 16, 2023
0.1.0 Jun 3, 2023

#291 in Unix APIs

Download history 215/week @ 2024-03-13 417/week @ 2024-03-20 230/week @ 2024-03-27 735/week @ 2024-04-03 160/week @ 2024-04-10 267/week @ 2024-04-17 162/week @ 2024-04-24 363/week @ 2024-05-01 369/week @ 2024-05-08 295/week @ 2024-05-15 249/week @ 2024-05-22 749/week @ 2024-05-29 557/week @ 2024-06-05 313/week @ 2024-06-12 324/week @ 2024-06-19 427/week @ 2024-06-26

1,639 downloads per month
Used in upstream-ontologist

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–6MB
~133K SLoC