pub enum ParsedEntry {
LineBased(Entry),
Deb822(Entry),
}Expand description
Parsed watch entry that can be either line-based or deb822 format
Variants§
Implementations§
Source§impl ParsedEntry
impl ParsedEntry
Sourcepub fn matching_pattern(&self) -> Option<String>
pub fn matching_pattern(&self) -> Option<String>
Get the matching pattern
Sourcepub fn get_option(&self, key: &str) -> Option<String>
pub fn get_option(&self, key: &str) -> Option<String>
Get a generic option/field value by key (case-insensitive)
This handles the difference between line-based format (lowercase keys) and deb822 format (capitalized keys). It tries the key as-is first, then tries with the first letter capitalized.
Sourcepub fn has_option(&self, key: &str) -> bool
pub fn has_option(&self, key: &str) -> bool
Check if an option/field is set (case-insensitive)
Sourcepub fn format_url(
&self,
package: impl FnOnce() -> String,
) -> Result<Url, ParseError>
pub fn format_url( &self, package: impl FnOnce() -> String, ) -> Result<Url, ParseError>
Format the URL with package substitution
Sourcepub fn user_agent(&self) -> Option<String>
pub fn user_agent(&self) -> Option<String>
Get the user agent
Sourcepub fn pagemangle(&self) -> Option<String>
pub fn pagemangle(&self) -> Option<String>
Get the pagemangle option
Sourcepub fn uversionmangle(&self) -> Option<String>
pub fn uversionmangle(&self) -> Option<String>
Get the uversionmangle option
Sourcepub fn downloadurlmangle(&self) -> Option<String>
pub fn downloadurlmangle(&self) -> Option<String>
Get the downloadurlmangle option
Sourcepub fn pgpsigurlmangle(&self) -> Option<String>
pub fn pgpsigurlmangle(&self) -> Option<String>
Get the pgpsigurlmangle option
Sourcepub fn filenamemangle(&self) -> Option<String>
pub fn filenamemangle(&self) -> Option<String>
Get the filenamemangle option
Sourcepub fn oversionmangle(&self) -> Option<String>
pub fn oversionmangle(&self) -> Option<String>
Get the oversionmangle option
Sourcepub fn searchmode(&self) -> SearchMode
pub fn searchmode(&self) -> SearchMode
Get the searchmode, with default fallback
Sourcepub fn set_option(&mut self, option: WatchOption)
pub fn set_option(&mut self, option: WatchOption)
Set an option/field value using a WatchOption enum (only supported for deb822 format).
For v5 (deb822) entries, this sets a field in the paragraph. For v1-4 (line-based) entries, this is not supported as entries are immutable.
§Examples
use debian_watch::parse::ParsedWatchFile;
use debian_watch::{WatchOption, Compression};
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()));
entry.set_option(WatchOption::Compression(Compression::Xz));Sourcepub fn set_url(&mut self, url: &str)
pub fn set_url(&mut self, url: &str)
Set the URL/Source of the entry
§Examples
use debian_watch::parse::ParsedWatchFile;
let mut wf = ParsedWatchFile::new(4).unwrap();
let mut entry = wf.add_entry("https://github.com/foo/bar/tags", ".*/v?([\\d.]+)\\.tar\\.gz");
entry.set_url("https://github.com/foo/bar/releases");
assert_eq!(entry.url(), "https://github.com/foo/bar/releases");Sourcepub fn set_matching_pattern(&mut self, pattern: &str)
pub fn set_matching_pattern(&mut self, pattern: &str)
Set the matching pattern of the entry
§Examples
use debian_watch::parse::ParsedWatchFile;
let mut wf = ParsedWatchFile::new(4).unwrap();
let mut entry = wf.add_entry("https://github.com/foo/bar/tags", ".*/v?([\\d.]+)\\.tar\\.gz");
entry.set_matching_pattern(".*/release-([\\d.]+)\\.tar\\.gz");
assert_eq!(entry.matching_pattern(), Some(".*/release-([\\d.]+)\\.tar\\.gz".to_string()));Sourcepub fn line(&self) -> usize
pub fn line(&self) -> usize
Get the line number (0-indexed) where this entry starts
For line-based formats (v1-4), this returns the actual line number in the file. For deb822 format (v5), this returns the line where the paragraph starts.
§Examples
use debian_watch::parse::parse;
let content = "version=4\nhttps://example.com/ .*.tar.gz\nhttps://example2.com/ .*.tar.gz";
let wf = parse(content).unwrap();
let entries: Vec<_> = wf.entries().collect();
assert_eq!(entries[0].line(), 1); // Second line (0-indexed)
assert_eq!(entries[1].line(), 2); // Third line (0-indexed)