pub struct Entry(/* private fields */);Expand description
A node in the syntax tree for $ast
Implementations§
Source§impl Entry
impl Entry
Source§impl Entry
impl Entry
Sourcepub fn builder(url: impl Into<String>) -> EntryBuilder
pub fn builder(url: impl Into<String>) -> EntryBuilder
Create a new entry builder.
This is a convenience method that returns an EntryBuilder.
§Examples
use debian_watch::Entry;
let entry = Entry::builder("https://github.com/example/tags")
.matching_pattern(".*/v?(\\d\\S+)\\.tar\\.gz")
.build();Sourcepub fn option_list(&self) -> Option<OptionList>
pub fn option_list(&self) -> Option<OptionList>
List of options
Sourcepub fn get_option(&self, key: &str) -> Option<String>
pub fn get_option(&self, key: &str) -> Option<String>
Get the value of an option
Sourcepub fn has_option(&self, key: &str) -> bool
pub fn has_option(&self, key: &str) -> bool
Check if an option is set
Sourcepub fn compression(&self) -> Result<Option<Compression>, ()>
pub fn compression(&self) -> Result<Option<Compression>, ()>
Compression method
Sourcepub fn repacksuffix(&self) -> Option<String>
pub fn repacksuffix(&self) -> Option<String>
Repack suffix
Sourcepub fn date(&self) -> String
pub fn date(&self) -> String
Set the date string used by the pretty option to an arbitrary format as an optional opts argument when the matching-pattern is HEAD or heads/branch for git mode.
Sourcepub fn searchmode(&self) -> Result<SearchMode, ()>
pub fn searchmode(&self) -> Result<SearchMode, ()>
Return the search mode
Sourcepub fn decompress(&self) -> bool
pub fn decompress(&self) -> bool
Return the decompression mode
Sourcepub fn bare(&self) -> bool
pub fn bare(&self) -> bool
Whether to disable all site specific special case code such as URL director uses and page content alterations.
Sourcepub fn user_agent(&self) -> Option<String>
pub fn user_agent(&self) -> Option<String>
Set the user-agent string used to contact the HTTP(S) server as user-agent-string. (persistent)
Sourcepub fn unzipoptions(&self) -> Option<String>
pub fn unzipoptions(&self) -> Option<String>
Add the extra options to use with the unzip command, such as -a, -aa, and -b, when executed by mk-origtargz.
Sourcepub fn dversionmangle(&self) -> Option<String>
pub fn dversionmangle(&self) -> Option<String>
Normalize the downloaded web page string.
Sourcepub fn dirversionmangle(&self) -> Option<String>
pub fn dirversionmangle(&self) -> Option<String>
Normalize the directory path string matching the regex in a set of parentheses of http://URL as the sortable version index string. This is used as the directory path sorting index only.
Sourcepub fn pagemangle(&self) -> Option<String>
pub fn pagemangle(&self) -> Option<String>
Normalize the downloaded web page string.
Sourcepub fn uversionmangle(&self) -> Option<String>
pub fn uversionmangle(&self) -> Option<String>
Normalize the candidate upstream version strings extracted from hrefs in the source of the web page. This is used as the version sorting index when selecting the latest upstream version.
Sourcepub fn versionmangle(&self) -> Option<String>
pub fn versionmangle(&self) -> Option<String>
Syntactic shorthand for uversionmangle=rules, dversionmangle=rules
Sourcepub fn hrefdecode(&self) -> bool
pub fn hrefdecode(&self) -> bool
Convert the selected upstream tarball href string from the percent-encoded hexadecimal string to the decoded normal URL string for obfuscated web sites. Only percent-encoding is available and it is decoded with s/%([A-Fa-f\d]{2})/chr hex $1/eg.
Sourcepub fn downloadurlmangle(&self) -> Option<String>
pub fn downloadurlmangle(&self) -> Option<String>
Convert the selected upstream tarball href string into the accessible URL for obfuscated web sites. This is run after hrefdecode.
Sourcepub fn filenamemangle(&self) -> Option<String>
pub fn filenamemangle(&self) -> Option<String>
Generate the upstream tarball filename from the selected href string if matching-pattern
can extract the latest upstream version
Without this option, the default upstream tarball filename is generated by taking the last component of the URL and removing everything after any ‘?’ or ‘#’.
Sourcepub fn pgpsigurlmangle(&self) -> Option<String>
pub fn pgpsigurlmangle(&self) -> Option<String>
Generate the candidate upstream signature file URL string from the upstream tarball URL.
Sourcepub fn oversionmangle(&self) -> Option<String>
pub fn oversionmangle(&self) -> Option<String>
Generate the version string
Sourcepub fn apply_uversionmangle(&self, version: &str) -> Result<String, MangleError>
pub fn apply_uversionmangle(&self, version: &str) -> Result<String, MangleError>
Apply uversionmangle to a version string
§Examples
let wf: WatchFile = r#"version=4
opts=uversionmangle=s/\+ds// https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(entry.apply_uversionmangle("1.0+ds").unwrap(), "1.0");Sourcepub fn apply_dversionmangle(&self, version: &str) -> Result<String, MangleError>
pub fn apply_dversionmangle(&self, version: &str) -> Result<String, MangleError>
Apply dversionmangle to a version string
§Examples
let wf: WatchFile = r#"version=4
opts=dversionmangle=s/\+dfsg$// https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(entry.apply_dversionmangle("1.0+dfsg").unwrap(), "1.0");Sourcepub fn apply_oversionmangle(&self, version: &str) -> Result<String, MangleError>
pub fn apply_oversionmangle(&self, version: &str) -> Result<String, MangleError>
Apply oversionmangle to a version string
§Examples
let wf: WatchFile = r#"version=4
opts=oversionmangle=s/$/-1/ https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(entry.apply_oversionmangle("1.0").unwrap(), "1.0-1");Sourcepub fn apply_dirversionmangle(
&self,
version: &str,
) -> Result<String, MangleError>
pub fn apply_dirversionmangle( &self, version: &str, ) -> Result<String, MangleError>
Apply dirversionmangle to a directory path string
§Examples
let wf: WatchFile = r#"version=4
opts=dirversionmangle=s/v(\d)/$1/ https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(entry.apply_dirversionmangle("v1.0").unwrap(), "1.0");Sourcepub fn apply_filenamemangle(&self, url: &str) -> Result<String, MangleError>
pub fn apply_filenamemangle(&self, url: &str) -> Result<String, MangleError>
Apply filenamemangle to a URL or filename string
§Examples
let wf: WatchFile = r#"version=4
opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/mypackage-$1.tar.gz/ https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(
entry.apply_filenamemangle("https://example.com/v1.0.tar.gz").unwrap(),
"mypackage-1.0.tar.gz"
);Sourcepub fn apply_pagemangle(&self, page: &[u8]) -> Result<Vec<u8>, MangleError>
pub fn apply_pagemangle(&self, page: &[u8]) -> Result<Vec<u8>, MangleError>
Apply pagemangle to page content bytes
§Examples
let wf: WatchFile = r#"version=4
opts=pagemangle=s/&/&/g https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(
entry.apply_pagemangle(b"foo & bar").unwrap(),
b"foo & bar"
);Sourcepub fn apply_downloadurlmangle(&self, url: &str) -> Result<String, MangleError>
pub fn apply_downloadurlmangle(&self, url: &str) -> Result<String, MangleError>
Apply downloadurlmangle to a URL string
§Examples
let wf: WatchFile = r#"version=4
opts=downloadurlmangle=s|/archive/|/download/| https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(
entry.apply_downloadurlmangle("https://example.com/archive/file.tar.gz").unwrap(),
"https://example.com/download/file.tar.gz"
);Sourcepub fn matching_pattern_node(&self) -> Option<MatchingPattern>
pub fn matching_pattern_node(&self) -> Option<MatchingPattern>
Returns the matching pattern AST node of the entry.
Sourcepub fn matching_pattern(&self) -> Option<String>
pub fn matching_pattern(&self) -> Option<String>
Returns the matching pattern of the entry.
Sourcepub fn version_node(&self) -> Option<VersionPolicyNode>
pub fn version_node(&self) -> Option<VersionPolicyNode>
Returns the version policy AST node of the entry.
Sourcepub fn script_node(&self) -> Option<ScriptNode>
pub fn script_node(&self) -> Option<ScriptNode>
Returns the script AST node of the entry.
Sourcepub fn format_url(&self, package: impl FnOnce() -> String) -> Url
pub fn format_url(&self, package: impl FnOnce() -> String) -> Url
Replace all substitutions and return the resulting URL.
Sourcepub fn set_matching_pattern(&mut self, new_pattern: &str)
pub fn set_matching_pattern(&mut self, new_pattern: &str)
Set the matching pattern of the entry.
TODO: This currently only replaces an existing matching pattern. If the entry doesn’t have a matching pattern, this method does nothing. Future implementation should insert the node at the correct position.
Sourcepub fn set_version_policy(&mut self, new_policy: &str)
pub fn set_version_policy(&mut self, new_policy: &str)
Set the version policy of the entry.
TODO: This currently only replaces an existing version policy. If the entry doesn’t have a version policy, this method does nothing. Future implementation should insert the node at the correct position.
Sourcepub fn set_script(&mut self, new_script: &str)
pub fn set_script(&mut self, new_script: &str)
Set the script of the entry.
TODO: This currently only replaces an existing script. If the entry doesn’t have a script, this method does nothing. Future implementation should insert the node at the correct position.