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.
For v5 (deb822) entries, this sets a field in the paragraph. For v1-4 (line-based) entries, this sets an option in the opts= list.
§Examples
use debian_watch::parse::ParsedWatchFile;
use debian_watch::{WatchOption, Compression};
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_option(WatchOption::Component("upstream".to_string()));
entry.set_option(WatchOption::Compression(Compression::Xz));
assert_eq!(entry.get_option("component"), Some("upstream".to_string()));
assert_eq!(entry.get_option("compression"), Some("xz".to_string()));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)Sourcepub fn remove_option(&mut self, option: WatchOption)
pub fn remove_option(&mut self, option: WatchOption)
Remove/delete an option from the entry
For v5 (deb822) entries, this removes a field from the paragraph. For v1-4 (line-based) entries, this removes an option from the opts= list. If this is the last option in a line-based entry, the entire opts= declaration is removed.
§Examples
use debian_watch::parse::ParsedWatchFile;
use debian_watch::WatchOption;
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_option(WatchOption::Compression(debian_watch::Compression::Xz));
assert!(entry.has_option("compression"));
entry.remove_option(WatchOption::Compression(debian_watch::Compression::Xz));
assert!(!entry.has_option("compression"));Sourcepub fn mode(&self) -> Result<Mode, ParseError>
pub fn mode(&self) -> Result<Mode, ParseError>
Retrieve the mode of the watch file entry.
Returns the mode with default fallback to Mode::LWP if not specified.
Returns an error if the mode value is invalid.
§Examples
use debian_watch::parse::ParsedWatchFile;
use debian_watch::{WatchOption, Mode};
let mut wf = ParsedWatchFile::new(4).unwrap();
let mut entry = wf.add_entry("https://github.com/foo/bar/tags", ".*/v?([\\d.]+)\\.tar\\.gz");
// Default mode is LWP
assert_eq!(entry.mode().unwrap(), Mode::LWP);
// Set git mode
entry.set_option(WatchOption::Mode(Mode::Git));
assert_eq!(entry.mode().unwrap(), Mode::Git);