pub struct TemplatedControlEditor { /* private fields */ }Expand description
An editor for a control file that may be generated from a template.
This editor will automatically expand the template if it does not exist. It will also automatically update the template if the control file is changed.
§Example
use std::path::Path;
use debian_analyzer::control::TemplatedControlEditor;
let td = tempfile::tempdir().unwrap();
let mut editor = TemplatedControlEditor::create(td.path().join("control")).unwrap();
editor.add_source("foo").set_architecture(Some("all"));
editor.commit().unwrap();Implementations§
Source§impl TemplatedControlEditor
impl TemplatedControlEditor
Sourcepub fn create<P: AsRef<Path>>(control_path: P) -> Result<Self, EditorError>
pub fn create<P: AsRef<Path>>(control_path: P) -> Result<Self, EditorError>
Create a new control file editor.
Sourcepub fn template_type(&self) -> Option<TemplateType>
pub fn template_type(&self) -> Option<TemplateType>
Return the type of the template used to generate the control file.
Sourcepub fn open<P: AsRef<Path>>(control_path: P) -> Result<Self, EditorError>
pub fn open<P: AsRef<Path>>(control_path: P) -> Result<Self, EditorError>
Open an existing control file.
Methods from Deref<Target = 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 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
Trait Implementations§
Source§impl DerefMut for TemplatedControlEditor
impl DerefMut for TemplatedControlEditor
Source§impl Editor<Control> for TemplatedControlEditor
impl Editor<Control> for TemplatedControlEditor
Source§fn orig_content(&self) -> Option<&[u8]>
fn orig_content(&self) -> Option<&[u8]>
The original content, if any - without reformatting
Source§fn rewritten_content(&self) -> Option<&[u8]>
fn rewritten_content(&self) -> Option<&[u8]>
The original content, but rewritten with our parser/serializer
Source§fn is_generated(&self) -> bool
fn is_generated(&self) -> bool
Check if the file is generated
Source§fn has_changed(&self) -> bool
fn has_changed(&self) -> bool
Whether the file has changed
Auto Trait Implementations§
impl Freeze for TemplatedControlEditor
impl !RefUnwindSafe for TemplatedControlEditor
impl !Send for TemplatedControlEditor
impl !Sync for TemplatedControlEditor
impl Unpin for TemplatedControlEditor
impl !UnwindSafe for TemplatedControlEditor
Blanket Implementations§
Source§impl<E> AbstractControlEditor for E
impl<E> AbstractControlEditor for E
Source§fn source<'a>(&'a mut self) -> Option<Box<dyn AbstractSource<'a> + 'a>>
fn source<'a>(&'a mut self) -> Option<Box<dyn AbstractSource<'a> + 'a>>
Get the source package.
Source§fn wrap_and_sort(&mut self)
fn wrap_and_sort(&mut self)
Wrap and sort the control file.
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