Skip to main content

Entry

Struct Entry 

Source
pub struct Entry { /* private fields */ }
Expand description

An entry in a format 5 watch file

Implementations§

Source§

impl Entry

Source

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.

Source

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.

Source

pub fn as_deb822(&self) -> &Paragraph

Get the underlying paragraph

Source

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

Name of the component, if specified

Source

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

Get the an option value from the entry, with fallback to defaults paragraph.

Source

pub fn set_option(&mut self, option: WatchOption)

Set an option value in the entry using a WatchOption enum

Source

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)

Source

pub fn delete_option(&mut self, option: WatchOption)

Delete an option from the entry using a WatchOption enum

Source

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

Delete an option from the entry using a string key (for backward compatibility)

Source

pub fn url(&self) -> String

Get the URL (same as source() but named url() for consistency)

Source

pub fn version_policy(&self) -> Result<Option<VersionPolicy>, TypesParseError>

Get the version policy

Source

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

Get the script

Source

pub fn set_source(&mut self, url: &str)

Set the source URL

Source

pub fn set_matching_pattern(&mut self, pattern: &str)

Set the matching pattern

Source

pub fn line(&self) -> usize

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

Source

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

Retrieve the mode of the watch file entry with detailed error information.

Source

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

Trait Implementations§

Source§

impl Debug for Entry

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl !RefUnwindSafe for Entry

§

impl !Send for Entry

§

impl !Sync for Entry

§

impl Unpin for Entry

§

impl UnsafeUnpin 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> 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.