Entry

Struct Entry 

Source
pub struct Entry(/* private fields */);
Expand description

A node in the syntax tree for $ast

Implementations§

Source§

impl Entry

Source

pub fn line(&self) -> usize

Get the line number (0-indexed) where this node starts.

Source

pub fn column(&self) -> usize

Get the column number (0-indexed, in bytes) where this node starts.

Source

pub fn line_col(&self) -> (usize, usize)

Get both line and column (0-indexed) where this node starts. Returns (line, column) where column is measured in bytes from the start of the line.

Source§

impl Entry

Source

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();
Source

pub fn option_list(&self) -> Option<OptionList>

List of options

Source

pub fn get_option(&self, key: &str) -> Option<String>

Get the value of an option

Source

pub fn has_option(&self, key: &str) -> bool

Check if an option is set

Source

pub fn component(&self) -> Option<String>

The name of the secondary source tarball

Source

pub fn ctype(&self) -> Result<Option<ComponentType>, ()>

Component type

Source

pub fn compression(&self) -> Result<Option<Compression>, ()>

Compression method

Source

pub fn repack(&self) -> bool

Repack the tarball

Source

pub fn repacksuffix(&self) -> Option<String>

Repack suffix

Source

pub fn mode(&self) -> Result<Mode, ()>

Retrieve the mode of the watch file entry.

Source

pub fn pretty(&self) -> Result<Pretty, ()>

Return the git pretty mode

Source

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.

Source

pub fn gitexport(&self) -> Result<GitExport, ()>

Return the git export mode

Source

pub fn gitmode(&self) -> Result<GitMode, ()>

Return the git mode

Source

pub fn pgpmode(&self) -> Result<PgpMode, ()>

Return the pgp mode

Source

pub fn searchmode(&self) -> Result<SearchMode, ()>

Return the search mode

Source

pub fn decompress(&self) -> bool

Return the decompression mode

Source

pub fn bare(&self) -> bool

Whether to disable all site specific special case code such as URL director uses and page content alterations.

Source

pub fn user_agent(&self) -> Option<String>

Set the user-agent string used to contact the HTTP(S) server as user-agent-string. (persistent)

Source

pub fn passive(&self) -> Option<bool>

Use PASV mode for the FTP connection.

Source

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.

Source

pub fn dversionmangle(&self) -> Option<String>

Normalize the downloaded web page string.

Source

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.

Source

pub fn pagemangle(&self) -> Option<String>

Normalize the downloaded web page string.

Source

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.

Source

pub fn versionmangle(&self) -> Option<String>

Syntactic shorthand for uversionmangle=rules, dversionmangle=rules

Source

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.

Source

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.

Source

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 from the selected href string. Otherwise, generate the upstream tarball filename from its full URL string and set the missing from the generated upstream tarball filename.

Without this option, the default upstream tarball filename is generated by taking the last component of the URL and removing everything after any ‘?’ or ‘#’.

Source

pub fn pgpsigurlmangle(&self) -> Option<String>

Generate the candidate upstream signature file URL string from the upstream tarball URL.

Source

pub fn oversionmangle(&self) -> Option<String>

Generate the version string of the source tarball _.orig.tar.gz from . This should be used to add a suffix such as +dfsg to a MUT package.

Source

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");
Source

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");
Source

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");
Source

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");
Source

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"
);
Source

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/&amp;/&/g https://example.com/ .*
"#.parse().unwrap();
let entry = wf.entries().next().unwrap();
assert_eq!(
    entry.apply_pagemangle(b"foo &amp; bar").unwrap(),
    b"foo & bar"
);
Source

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"
);
Source

pub fn opts(&self) -> HashMap<String, String>

Returns options set

Source

pub fn url_node(&self) -> Option<Url>

Returns the URL AST node of the entry.

Source

pub fn url(&self) -> String

Returns the URL of the entry.

Source

pub fn matching_pattern_node(&self) -> Option<MatchingPattern>

Returns the matching pattern AST node of the entry.

Source

pub fn matching_pattern(&self) -> Option<String>

Returns the matching pattern of the entry.

Source

pub fn version_node(&self) -> Option<VersionPolicyNode>

Returns the version policy AST node of the entry.

Source

pub fn version(&self) -> Result<Option<VersionPolicy>, String>

Returns the version policy

Source

pub fn script_node(&self) -> Option<ScriptNode>

Returns the script AST node of the entry.

Source

pub fn script(&self) -> Option<String>

Returns the script of the entry.

Source

pub fn format_url(&self, package: impl FnOnce() -> String) -> Url

Replace all substitutions and return the resulting URL.

Source

pub fn set_url(&mut self, new_url: &str)

Set the URL of the entry.

Source

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.

Source

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.

Source

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.

Source

pub fn set_opt(&mut self, key: &str, value: &str)

Set or update an option value.

If the option already exists, it will be updated with the new value. If the option doesn’t exist, it will be added to the options list. If there’s no options list, one will be created.

Source

pub fn del_opt(&mut self, key: &str)

Delete an option.

Removes the option with the specified key from the options list. If the option doesn’t exist, this method does nothing. If deleting the option results in an empty options list, the entire opts= declaration is removed.

Trait Implementations§

Source§

impl Clone for Entry

Source§

fn clone(&self) -> Entry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Hash for Entry

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Entry

Source§

fn eq(&self, other: &Entry) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToString for Entry

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl Eq for Entry

Source§

impl StructuralPartialEq for Entry

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl !RefUnwindSafe for Entry

§

impl !Send for Entry

§

impl !Sync for Entry

§

impl Unpin for Entry

§

impl !UnwindSafe for Entry

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.