pub struct Entry { /* private fields */ }Expand description
An entry in a format 5 watch file
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn source(&self) -> Result<Option<String>, TemplateError>
pub fn source(&self) -> Result<Option<String>, TemplateError>
Returns the source URL, expanding templates if present
Returns Ok(None) if no Source field is set and no template is present.
Returns Err if template expansion fails.
Sourcepub fn matching_pattern(&self) -> Result<Option<String>, TemplateError>
pub fn matching_pattern(&self) -> Result<Option<String>, TemplateError>
Returns the matching pattern, expanding templates if present
Returns Ok(None) if no Matching-Pattern field is set and no template is present.
Returns Err if template expansion fails.
Sourcepub fn get_option(&self, key: &str) -> Option<String>
pub fn get_option(&self, key: &str) -> Option<String>
Get the an option value from the entry, with fallback to defaults paragraph.
Sourcepub fn set_option(&mut self, option: WatchOption)
pub fn set_option(&mut self, option: WatchOption)
Set an option value in the entry using a WatchOption enum
Sourcepub fn set_option_str(&mut self, key: &str, value: &str)
pub fn set_option_str(&mut self, key: &str, value: &str)
Set an option value in the entry using string key and value (for backward compatibility)
Sourcepub fn delete_option(&mut self, option: WatchOption)
pub fn delete_option(&mut self, option: WatchOption)
Delete an option from the entry using a WatchOption enum
Sourcepub fn delete_option_str(&mut self, key: &str)
pub fn delete_option_str(&mut self, key: &str)
Delete an option from the entry using a string key (for backward compatibility)
Sourcepub fn version_policy(&self) -> Result<Option<VersionPolicy>, TypesParseError>
pub fn version_policy(&self) -> Result<Option<VersionPolicy>, TypesParseError>
Get the version policy
Sourcepub fn set_source(&mut self, url: &str)
pub fn set_source(&mut self, url: &str)
Set the source URL
Sourcepub fn set_matching_pattern(&mut self, pattern: &str)
pub fn set_matching_pattern(&mut self, pattern: &str)
Set the matching pattern
Sourcepub fn mode(&self) -> Result<Mode, TypesParseError>
pub fn mode(&self) -> Result<Mode, TypesParseError>
Retrieve the mode of the watch file entry with detailed error information.
Sourcepub fn try_convert_to_template(&mut self) -> Option<Template>
pub fn try_convert_to_template(&mut self) -> Option<Template>
Try to detect if this entry matches a template pattern and convert it to use that template.
This analyzes the Source, Matching-Pattern, Searchmode, and Mode fields to determine if they match a known template pattern. If a match is found, the entry is converted to use the template syntax instead.
§Returns
Returns Some(template) if a template was detected and applied, None if no
template matches the current entry configuration.
§Example
use debian_watch::deb822::WatchFile;
let mut wf = WatchFile::new();
let mut entry = wf.add_entry(
"https://github.com/torvalds/linux/tags",
r".*/(?:refs/tags/)?v?@ANY_VERSION@@ARCHIVE_EXT@"
);
entry.set_option_str("Searchmode", "html");
// Convert to template
if let Some(template) = entry.try_convert_to_template() {
println!("Converted to {:?}", template);
}