pub struct Control(/* private fields */);
Expand description
A Debian control file
Implementations§
Source§impl Control
impl Control
Sourcepub fn as_mut_deb822(&mut self) -> &mut Deb822
pub fn as_mut_deb822(&mut self) -> &mut Deb822
Return the underlying deb822 object, mutable
Sourcepub fn add_source(&mut self, name: &str) -> Source
pub fn add_source(&mut self, name: &str) -> Source
Sourcepub fn add_binary(&mut self, name: &str) -> Binary
pub fn add_binary(&mut self, name: &str) -> Binary
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>
Read a control file from a file
Sourcepub fn from_file_relaxed<P: AsRef<Path>>(
path: P,
) -> Result<(Self, Vec<String>), Error>
pub fn from_file_relaxed<P: AsRef<Path>>( path: P, ) -> Result<(Self, Vec<String>), Error>
Read a control file from a file, allowing syntax errors
Sourcepub fn read_relaxed<R: Read>(r: R) -> Result<(Self, Vec<String>), Error>
pub fn read_relaxed<R: Read>(r: R) -> Result<(Self, Vec<String>), Error>
Read a control file from a reader, allowing syntax errors
Sourcepub fn wrap_and_sort(
&mut self,
indentation: Indentation,
immediate_empty_line: bool,
max_line_length_one_liner: Option<usize>,
)
pub fn wrap_and_sort( &mut self, indentation: Indentation, immediate_empty_line: bool, max_line_length_one_liner: Option<usize>, )
Wrap and sort the control file
§Arguments
indentation
- The indentation to useimmediate_empty_line
- Whether to add an empty line at the start of multi-line fieldsmax_line_length_one_liner
- The maximum line length for one-liner fields
Sourcepub fn fields_in_range(
&self,
range: TextRange,
) -> impl Iterator<Item = Entry> + '_
pub fn fields_in_range( &self, range: TextRange, ) -> impl Iterator<Item = Entry> + '_
Iterate over fields that overlap with the given range
This method returns all fields (entries) from all paragraphs that have any overlap with the specified text range. This is useful for incremental parsing in LSP contexts where you only want to process fields that were affected by a text change.
§Arguments
range
- The text range to check for overlaps
§Returns
An iterator over all Entry items that overlap with the given range
§Example
use debian_control::lossless::Control;
use deb822_lossless::TextRange;
let control_text = "Source: foo\nMaintainer: test@example.com\n\nPackage: bar\nArchitecture: all\n";
let control: Control = control_text.parse().unwrap();
// Get fields in a specific range (e.g., where a change occurred)
let change_range = TextRange::new(20.into(), 40.into());
for entry in control.fields_in_range(change_range) {
if let Some(key) = entry.key() {
println!("Field {} was in the changed range", key);
}
}
Trait Implementations§
Source§impl AstNode for Control
impl AstNode for Control
type Language = Lang
fn can_cast(kind: <Self::Language as Language>::Kind) -> bool
fn cast(syntax: SyntaxNode<Self::Language>) -> Option<Self>
fn syntax(&self) -> &SyntaxNode<Self::Language>
fn clone_for_update(&self) -> Selfwhere
Self: Sized,
fn clone_subtree(&self) -> Selfwhere
Self: Sized,
impl Eq for Control
impl StructuralPartialEq for Control
Auto Trait Implementations§
impl Freeze for Control
impl !RefUnwindSafe for Control
impl !Send for Control
impl !Sync for Control
impl Unpin for Control
impl !UnwindSafe for Control
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more