Crate debian_watch

Crate debian_watch 

Source
Expand description

Formatting-preserving parser and editor for Debian watch files

§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"));

Structs§

Entry
A node in the syntax tree for $ast
EntryV5
An entry in a format 5 watch file
Parse
Thread-safe parse result that can be stored in incremental computation systems like Salsa. The type parameter T represents the root AST node type (e.g., WatchFile).
ParseError
Error type for parsing watch file types
WatchFile
A node in the syntax tree for $ast
WatchFileV5
A watch file in format 5 (RFC822/deb822 style)

Enums§

ComponentType
The type of the component
Compression
Compression type
ConversionError
Error type for conversion failures
GitExport
Git export mode
GitMode
Git clone operation mode
Mode
Archive download mode
PgpMode
PGP verification mode
Pretty
How to generate upstream version string from git tags
SearchMode
How to search for the upstream tarball
VersionPolicy
The version policy to use when downloading upstream tarballs

Constants§

DEFAULT_VERSION
Any watch files without a version are assumed to be version 1.

Traits§

WatchEntry
Common trait for watch file entries across all formats
WatchFileFormat
Common trait for all watch file format versions

Functions§

convert_to_v5
Convert a watch file from formats 1-4 to format 5
parse_watch_file
Parse a watch file and return a thread-safe parse result. This can be stored in incremental computation systems like Salsa.