BinaryPackageControlFile

Struct BinaryPackageControlFile 

Source
pub struct BinaryPackageControlFile<'a> { /* private fields */ }
Expand description

A Debian binary package control file/paragraph.

See https://www.debian.org/doc/debian-policy/ch-controlfields.html#binary-package-control-files-debian-control.

Binary package control files are defined by a single paragraph with well-defined fields. This type is a low-level wrapper around an inner ControlParagraph. Deref and DerefMut can be used to operate on the inner ControlParagraph. From and Into are implemented in both directions to enable cheap coercion between the types.

Binary package control paragraphs are seen in DEBIAN/control files. Variations also exist in Packages files in repositories and elsewhere.

Fields annotated as mandatory in the Debian Policy Manual have getters that return Result and will error if a field is not present. Non-mandatory fields return Option. This enforcement can be bypassed by calling ControlParagraph::field().

Implementations§

Source§

impl<'a> BinaryPackageControlFile<'a>

Source

pub fn package(&self) -> Result<&str>

The Package field value.

Source

pub fn version_str(&self) -> Result<&str>

The Version field as its original string.

Source

pub fn version(&self) -> Result<PackageVersion>

The Version field parsed into a PackageVersion.

Source

pub fn architecture(&self) -> Result<&str>

The Architecture field.

Source

pub fn maintainer(&self) -> Result<&str>

The Maintainer field.

Source

pub fn description(&self) -> Result<&str>

The Description field.

Source

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

The Source field.

Source

pub fn section(&self) -> Option<&str>

The Section field.

Source

pub fn priority(&self) -> Option<&str>

The Priority field.

Source

pub fn essential(&self) -> Option<&str>

The Essential field.

Source

pub fn homepage(&self) -> Option<&str>

The Homepage field.

Source

pub fn installed_size(&self) -> Option<Result<u64>>

The Installed-Size field, parsed to a u64.

Source

pub fn size(&self) -> Option<Result<u64>>

The Size field, parsed to a u64.

Source

pub fn built_using(&self) -> Option<&str>

The Built-Using field.

Source

pub fn depends(&self) -> Option<Result<DependencyList>>

The Depends field, parsed to a DependencyList.

Source

pub fn recommends(&self) -> Option<Result<DependencyList>>

The Recommends field, parsed to a DependencyList.

Source

pub fn suggests(&self) -> Option<Result<DependencyList>>

The Suggests field, parsed to a DependencyList.

Source

pub fn enhances(&self) -> Option<Result<DependencyList>>

The Enhances field, parsed to a DependencyList.

Source

pub fn pre_depends(&self) -> Option<Result<DependencyList>>

The Pre-Depends field, parsed to a DependencyList.

Source

pub fn package_dependency_fields(&self) -> Result<PackageDependencyFields>

Obtain parsed values of all fields defining dependencies.

Methods from Deref<Target = ControlParagraph<'a>>§

Source

pub fn is_empty(&self) -> bool

Whether the paragraph is empty.

Empty is defined by the lack of any fields.

Source

pub fn set_field(&mut self, field: ControlField<'a>)

Set the value of a field via a ControlField.

If a field with the same name (case insensitive compare) already exists, the old value will be replaced by the incoming value.

Source

pub fn set_field_from_string(&mut self, name: Cow<'a, str>, value: Cow<'a, str>)

Set the value of a field defined via strings.

If a field with the same name (case insensitive compare) already exists, the old value will be replaced by the incoming value.

Source

pub fn has_field(&self, name: &str) -> bool

Whether a named field is present in this paragraph.

Source

pub fn iter_fields(&self) -> impl Iterator<Item = &ControlField<'a>>

Iterate over fields in this paragraph.

Iteration order is insertion order.

Source

pub fn field(&self, name: &str) -> Option<&ControlField<'a>>

Obtain the field with a given name in this paragraph.

Source

pub fn field_mut(&mut self, name: &str) -> Option<&'a mut ControlField<'_>>

Obtain a mutable reference to the field with a given name.

Source

pub fn required_field(&self, name: &str) -> Result<&ControlField<'a>>

Obtain the named field and error if it isn’t defined.

Source

pub fn field_str(&self, name: &str) -> Option<&str>

Obtain the raw string value of the named field.

Source

pub fn required_field_str(&self, name: &str) -> Result<&str>

Obtain the raw string value of the named field, erroring if the field is not present.

Source

pub fn field_bool(&self, name: &str) -> Option<bool>

Obtain the value of a field, evaluated as a boolean.

The field is true iff its string value is yes.

Source

pub fn field_u64(&self, name: &str) -> Option<Result<u64>>

Obtain the value of a field, evaluated as a u64.

Source

pub fn field_dependency_list( &self, name: &str, ) -> Option<Result<DependencyList>>

Obtain the value of a field, parsed as a DependencyList.

Source

pub fn field_datetime_rfc5322( &self, name: &str, ) -> Option<Result<DateTime<Utc>>>

Obtain the value of a field parsed as an RFC 5322 date string.

This will parse values like Sat, 09 Oct 2021 09:34:56 UTC.

The timezone is always normalized to UTC even if it is expressed differently in the source string.

Source

pub fn field_simple(&self, name: &str) -> Option<Result<ControlFieldValue<'a>>>

Obtain the field with the given name as a ControlFieldValue::Simple, if possible.

Source

pub fn field_folded(&self, name: &str) -> Option<ControlFieldValue<'a>>

Obtain the field with the given name as a ControlFieldValue::Folded.

Source

pub fn field_multiline(&self, name: &str) -> Option<ControlFieldValue<'a>>

Obtain the field with the given name as a ControlFieldValue::Multiline.

Source

pub fn iter_field_words( &self, name: &str, ) -> Option<Box<dyn Iterator<Item = &str> + '_>>

Obtain an iterator of words in the named field.

Source

pub fn iter_field_lines( &self, name: &str, ) -> Option<Box<dyn Iterator<Item = &str> + '_>>

Obtain an iterator of lines in the named field.

Source

pub fn iter_field_comma_delimited( &self, name: &str, ) -> Option<Box<dyn Iterator<Item = &str> + '_>>

Obtain an iterator of comma-delimited values in the named field.

Source

pub fn as_str_hash_map(&self) -> HashMap<&str, &str>

Convert this paragraph to a HashMap.

Values will be the string normalization of the field value, including newlines and leading whitespace.

If a field occurs multiple times, its last value will be recorded in the returned map.

Source

pub fn write<W: Write>(&self, writer: &mut W) -> Result<()>

Serialize the paragraph to a writer.

A trailing newline is written as part of the final field. However, an extra newline is not present. So if serializing multiple paragraphs, an additional line break must be written to effectively terminate this paragraph if the writer is not at EOF.

Trait Implementations§

Source§

impl<'a> Clone for BinaryPackageControlFile<'a>

Source§

fn clone(&self) -> BinaryPackageControlFile<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'cf, 'a: 'cf> DebPackageReference<'cf> for BinaryPackageControlFile<'a>

Source§

fn deb_size_bytes(&self) -> Result<u64>

Obtain the size in bytes of the .deb file. Read more
Source§

fn deb_digest(&self, checksum: ChecksumType) -> Result<ContentDigest>

Obtains the binary digest of this file given a checksum flavor. Read more
Source§

fn deb_filename(&self) -> Result<String>

Obtain the filename of this .deb. Read more
Source§

fn control_file_for_packages_index( &self, ) -> Result<BinaryPackageControlFile<'cf>>

Obtain a BinaryPackageControlFile representing content for a Packages index file. Read more
Source§

impl<'a> Debug for BinaryPackageControlFile<'a>

Source§

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

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

impl<'a> Deref for BinaryPackageControlFile<'a>

Source§

type Target = ControlParagraph<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> DerefMut for BinaryPackageControlFile<'a>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a> From<BinaryPackageControlFile<'a>> for ControlParagraph<'a>

Source§

fn from(cf: BinaryPackageControlFile<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<ControlParagraph<'a>> for BinaryPackageControlFile<'a>

Source§

fn from(paragraph: ControlParagraph<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> Hash for BinaryPackageControlFile<'a>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> Ord for BinaryPackageControlFile<'a>

Source§

fn cmp(&self, other: &BinaryPackageControlFile<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a> PartialEq for BinaryPackageControlFile<'a>

Source§

fn eq(&self, other: &BinaryPackageControlFile<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> PartialOrd for BinaryPackageControlFile<'a>

Source§

fn partial_cmp(&self, other: &BinaryPackageControlFile<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> Eq for BinaryPackageControlFile<'a>

Source§

impl<'a> StructuralPartialEq for BinaryPackageControlFile<'a>

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more