Struct Control

Source
pub struct Control(/* private fields */);
Expand description

A Debian control file

Implementations§

Source§

impl Control

Source

pub fn new() -> Self

Create a new control file

Source

pub fn as_mut_deb822(&mut self) -> &mut Deb822

Return the underlying deb822 object, mutable

Source

pub fn as_deb822(&self) -> &Deb822

Return the underlying deb822 object

Source

pub fn source(&self) -> Option<Source>

Return the source package

Source

pub fn binaries(&self) -> impl Iterator<Item = Binary>

Iterate over all binary packages

Source

pub fn add_source(&mut self, name: &str) -> Source

Add a new source package

§Arguments
  • name - The name of the source package
§Returns

The newly created source package

§Example
use debian_control::lossless::control::Control;
let mut control = Control::new();
let source = control.add_source("foo");
assert_eq!(source.name(), Some("foo".to_owned()));
Source

pub fn add_binary(&mut self, name: &str) -> Binary

Add new binary package

§Arguments
  • name - The name of the binary package
§Returns

The newly created binary package

§Example
use debian_control::lossless::control::Control;
let mut control = Control::new();
let binary = control.add_binary("foo");
assert_eq!(binary.name(), Some("foo".to_owned()));
Source

pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Read a control file from a file

Source

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

Source

pub fn read<R: Read>(r: R) -> Result<Self, Error>

Read a control file from a reader

Source

pub fn read_relaxed<R: Read>(r: R) -> Result<(Self, Vec<String>), Error>

Read a control file from a reader, allowing syntax errors

Source

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 use
  • immediate_empty_line - Whether to add an empty line at the start of multi-line fields
  • max_line_length_one_liner - The maximum line length for one-liner fields

Trait Implementations§

Source§

impl Default for Control

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Control

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Control> for Deb822

Source§

fn from(c: Control) -> Self

Converts to this type from the input type.
Source§

impl From<Deb822> for Control

Source§

fn from(d: Deb822) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Control

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T