10 releases

0.2.8 Nov 13, 2024
0.2.7 Mar 9, 2024
0.2.5 Oct 3, 2023
0.2.1 Sep 16, 2023
0.1.0 Jun 3, 2023

#4 in #original

Download history 363/week @ 2024-11-28 427/week @ 2024-12-05 386/week @ 2024-12-12 460/week @ 2024-12-19 277/week @ 2024-12-26 475/week @ 2025-01-02 266/week @ 2025-01-09 239/week @ 2025-01-16 171/week @ 2025-01-23 281/week @ 2025-01-30 2157/week @ 2025-02-06 3248/week @ 2025-02-13 712/week @ 2025-02-20 3423/week @ 2025-02-27 2996/week @ 2025-03-06 3877/week @ 2025-03-13

11,184 downloads per month
Used in upstream-ontologist

Apache-2.0

55KB
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

~6–8.5MB
~143K SLoC