pub enum ParsedWatchFile {
LineBased(WatchFile),
Deb822(WatchFile),
}Expand description
Parsed watch file that can be either line-based or deb822 format
Variants§
Implementations§
Source§impl ParsedWatchFile
impl ParsedWatchFile
Sourcepub fn snapshot(&self) -> Self
pub fn snapshot(&self) -> Self
Capture an independent snapshot of this watch file.
The returned value shares the underlying immutable green-node data
with self at the time of the call, but lives in its own mutable
tree: subsequent mutations to self do not propagate to the snapshot.
Pair with Self::tree_eq to detect later mutations.
Sourcepub fn tree_eq(&self, other: &Self) -> bool
pub fn tree_eq(&self, other: &Self) -> bool
Returns true iff the syntax trees of self and other are
value-equal. An O(1) pointer-identity fast path makes this free for
trees that still share state with a recent Self::snapshot.
Mismatched variants are never considered equal.
Sourcepub fn new(version: u32) -> Result<Self, ParseError>
pub fn new(version: u32) -> Result<Self, ParseError>
Create a new empty watch file with the specified version.
- For version 5, creates a deb822-format watch file (requires
deb822feature) - For versions 1-4, creates a line-based watch file (requires
linebasedfeature)
§Examples
use debian_watch::parse::ParsedWatchFile;
let wf = ParsedWatchFile::new(5).unwrap();
assert_eq!(wf.version(), 5);Sourcepub fn entries(&self) -> impl Iterator<Item = ParsedEntry> + '_
pub fn entries(&self) -> impl Iterator<Item = ParsedEntry> + '_
Get an iterator over entries as ParsedEntry enum
Sourcepub fn add_entry(&mut self, source: &str, matching_pattern: &str) -> ParsedEntry
pub fn add_entry(&mut self, source: &str, matching_pattern: &str) -> ParsedEntry
Add a new entry to the watch file and return it.
For v5 (deb822) watch files, this adds a new paragraph with Source and Matching-Pattern fields. For v1-4 (line-based) watch files, this adds a new entry line.
Returns a ParsedEntry that can be used to query or modify the entry.
§Examples
use debian_watch::parse::ParsedWatchFile;
use debian_watch::WatchOption;
let mut wf = ParsedWatchFile::new(5).unwrap();
let mut entry = wf.add_entry("https://github.com/foo/bar/tags", ".*/v?([\\d.]+)\\.tar\\.gz");
entry.set_option(WatchOption::Component("upstream".to_string()));Sourcepub fn version_range(&self) -> Option<TextRange>
pub fn version_range(&self) -> Option<TextRange>
Byte range of the version declaration.
In line-based files this is the version=N directive on the
first line; in deb822 files it’s the Version: entry on the
header paragraph. Returns None when the file has no version
declaration (legal for v1 line-based files; unusual for v5).
Trait Implementations§
Source§impl Clone for ParsedWatchFile
impl Clone for ParsedWatchFile
Source§fn clone(&self) -> ParsedWatchFile
fn clone(&self) -> ParsedWatchFile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more