pub struct WatchFile(/* private fields */);Expand description
A node in the syntax tree for $ast
Implementations§
Source§impl WatchFile
impl WatchFile
Sourcepub fn text_range(&self) -> TextRange
pub fn text_range(&self) -> TextRange
Byte range covered by this node in the source buffer.
Useful for editors that need to map a logical concept (an option, a URL, a matching pattern) back to the exact span it occupies — e.g. to filter LSP diagnostics by which part of a watch entry was edited.
Source§impl WatchFile
impl WatchFile
Sourcepub fn syntax(&self) -> &SyntaxNode<Lang>
pub fn syntax(&self) -> &SyntaxNode<Lang>
Access the underlying syntax node
Sourcepub fn snapshot(&self) -> Self
pub fn snapshot(&self) -> Self
Capture an independent snapshot of this watch file.
See crate::parse::ParsedWatchFile::snapshot for semantics.
Sourcepub fn tree_eq(&self, other: &Self) -> bool
pub fn tree_eq(&self, other: &Self) -> bool
Returns true iff the syntax trees of self and other are
value-equal. An O(1) pointer-identity fast path makes this free for
trees that still share state with a recent snapshot().
Sourcepub fn version_node(&self) -> Option<Version>
pub fn version_node(&self) -> Option<Version>
Returns the version AST node of the watch file.
Sourcepub fn entries(&self) -> impl Iterator<Item = Entry> + '_
pub fn entries(&self) -> impl Iterator<Item = Entry> + '_
Returns an iterator over all entries in the watch file.
Sourcepub fn set_version(&mut self, new_version: u32)
pub fn set_version(&mut self, new_version: u32)
Set the version of the watch file.
Sourcepub fn add_entry(&mut self, entry: Entry) -> Entry
pub fn add_entry(&mut self, entry: Entry) -> Entry
Add an entry to the watch file.
Appends a new entry to the end of the watch file.
§Examples
use debian_watch::linebased::{WatchFile, EntryBuilder};
let mut wf = WatchFile::new(Some(4));
// Add an entry using EntryBuilder
let entry = EntryBuilder::new("https://github.com/example/tags")
.matching_pattern(".*/v?(\\d\\S+)\\.tar\\.gz")
.build();
wf.add_entry(entry);
// Or use the builder pattern directly
wf.add_entry(
EntryBuilder::new("https://example.com/releases")
.matching_pattern(".*/(\\d+\\.\\d+)\\.tar\\.gz")
.opt("compression", "xz")
.version_policy("debian")
.build()
);Sourcepub fn from_reader<R: Read>(reader: R) -> Result<WatchFile, ParseError>
pub fn from_reader<R: Read>(reader: R) -> Result<WatchFile, ParseError>
Read a watch file from a Read object.
Sourcepub fn from_reader_relaxed<R: Read>(r: R) -> Result<Self, Error>
pub fn from_reader_relaxed<R: Read>(r: R) -> Result<Self, Error>
Read a watch file from a Read object, allowing syntax errors.
Sourcepub fn from_str_relaxed(s: &str) -> Self
pub fn from_str_relaxed(s: &str) -> Self
Parse a debian watch file from a string, allowing syntax errors.