Skip to main content

ParsedEntry

Enum ParsedEntry 

Source
pub enum ParsedEntry {
    LineBased(Entry),
    Deb822(Entry),
}
Expand description

Parsed watch entry that can be either line-based or deb822 format

Variants§

§

LineBased(Entry)

Line-based entry (v1-4)

§

Deb822(Entry)

Deb822 entry (v5)

Implementations§

Source§

impl ParsedEntry

Source

pub fn url(&self) -> String

Get the URL/Source of the entry

Source

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

Get the matching pattern

Source

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.

Source

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

Check if an option/field is set (case-insensitive)

Source

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

Get the script

Source

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

Format the URL with package substitution

Source

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

Get the user agent

Source

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

Get the pagemangle option

Source

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

Get the uversionmangle option

Source

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

Get the downloadurlmangle option

Source

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

Get the pgpsigurlmangle option

Source

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

Get the filenamemangle option

Source

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

Get the oversionmangle option

Source

pub fn searchmode(&self) -> SearchMode

Get the searchmode, with default fallback

Source

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

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

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

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)

Trait Implementations§

Source§

impl Debug for ParsedEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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, 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.