debian_control::lossless::control

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§

default 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.