pub struct BinaryPackageControlFile<'a> { /* private fields */ }Expand description
A Debian binary package control file/paragraph.
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>
impl<'a> BinaryPackageControlFile<'a>
Sourcepub fn version_str(&self) -> Result<&str>
pub fn version_str(&self) -> Result<&str>
The Version field as its original string.
Sourcepub fn version(&self) -> Result<PackageVersion>
pub fn version(&self) -> Result<PackageVersion>
The Version field parsed into a PackageVersion.
Sourcepub fn architecture(&self) -> Result<&str>
pub fn architecture(&self) -> Result<&str>
The Architecture field.
Sourcepub fn maintainer(&self) -> Result<&str>
pub fn maintainer(&self) -> Result<&str>
The Maintainer field.
Sourcepub fn description(&self) -> Result<&str>
pub fn description(&self) -> Result<&str>
The Description field.
Sourcepub fn built_using(&self) -> Option<&str>
pub fn built_using(&self) -> Option<&str>
The Built-Using field.
Sourcepub fn depends(&self) -> Option<Result<DependencyList>>
pub fn depends(&self) -> Option<Result<DependencyList>>
The Depends field, parsed to a DependencyList.
Sourcepub fn recommends(&self) -> Option<Result<DependencyList>>
pub fn recommends(&self) -> Option<Result<DependencyList>>
The Recommends field, parsed to a DependencyList.
Sourcepub fn suggests(&self) -> Option<Result<DependencyList>>
pub fn suggests(&self) -> Option<Result<DependencyList>>
The Suggests field, parsed to a DependencyList.
Sourcepub fn enhances(&self) -> Option<Result<DependencyList>>
pub fn enhances(&self) -> Option<Result<DependencyList>>
The Enhances field, parsed to a DependencyList.
Sourcepub fn pre_depends(&self) -> Option<Result<DependencyList>>
pub fn pre_depends(&self) -> Option<Result<DependencyList>>
The Pre-Depends field, parsed to a DependencyList.
Sourcepub fn package_dependency_fields(&self) -> Result<PackageDependencyFields>
pub fn package_dependency_fields(&self) -> Result<PackageDependencyFields>
Obtain parsed values of all fields defining dependencies.
Methods from Deref<Target = ControlParagraph<'a>>§
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the paragraph is empty.
Empty is defined by the lack of any fields.
Sourcepub fn set_field(&mut self, field: ControlField<'a>)
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.
Sourcepub fn set_field_from_string(&mut self, name: Cow<'a, str>, value: Cow<'a, str>)
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.
Sourcepub fn has_field(&self, name: &str) -> bool
pub fn has_field(&self, name: &str) -> bool
Whether a named field is present in this paragraph.
Sourcepub fn iter_fields(&self) -> impl Iterator<Item = &ControlField<'a>>
pub fn iter_fields(&self) -> impl Iterator<Item = &ControlField<'a>>
Iterate over fields in this paragraph.
Iteration order is insertion order.
Sourcepub fn field(&self, name: &str) -> Option<&ControlField<'a>>
pub fn field(&self, name: &str) -> Option<&ControlField<'a>>
Obtain the field with a given name in this paragraph.
Sourcepub fn field_mut(&mut self, name: &str) -> Option<&'a mut ControlField<'_>>
pub fn field_mut(&mut self, name: &str) -> Option<&'a mut ControlField<'_>>
Obtain a mutable reference to the field with a given name.
Sourcepub fn required_field(&self, name: &str) -> Result<&ControlField<'a>>
pub fn required_field(&self, name: &str) -> Result<&ControlField<'a>>
Obtain the named field and error if it isn’t defined.
Sourcepub fn field_str(&self, name: &str) -> Option<&str>
pub fn field_str(&self, name: &str) -> Option<&str>
Obtain the raw string value of the named field.
Sourcepub fn required_field_str(&self, name: &str) -> Result<&str>
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.
Sourcepub fn field_bool(&self, name: &str) -> Option<bool>
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.
Sourcepub fn field_u64(&self, name: &str) -> Option<Result<u64>>
pub fn field_u64(&self, name: &str) -> Option<Result<u64>>
Obtain the value of a field, evaluated as a u64.
Sourcepub fn field_dependency_list(
&self,
name: &str,
) -> Option<Result<DependencyList>>
pub fn field_dependency_list( &self, name: &str, ) -> Option<Result<DependencyList>>
Obtain the value of a field, parsed as a DependencyList.
Sourcepub fn field_datetime_rfc5322(
&self,
name: &str,
) -> Option<Result<DateTime<Utc>>>
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.
Sourcepub fn field_simple(&self, name: &str) -> Option<Result<ControlFieldValue<'a>>>
pub fn field_simple(&self, name: &str) -> Option<Result<ControlFieldValue<'a>>>
Obtain the field with the given name as a ControlFieldValue::Simple, if possible.
Sourcepub fn field_folded(&self, name: &str) -> Option<ControlFieldValue<'a>>
pub fn field_folded(&self, name: &str) -> Option<ControlFieldValue<'a>>
Obtain the field with the given name as a ControlFieldValue::Folded.
Sourcepub fn field_multiline(&self, name: &str) -> Option<ControlFieldValue<'a>>
pub fn field_multiline(&self, name: &str) -> Option<ControlFieldValue<'a>>
Obtain the field with the given name as a ControlFieldValue::Multiline.
Sourcepub fn iter_field_words(
&self,
name: &str,
) -> Option<Box<dyn Iterator<Item = &str> + '_>>
pub fn iter_field_words( &self, name: &str, ) -> Option<Box<dyn Iterator<Item = &str> + '_>>
Obtain an iterator of words in the named field.
Sourcepub fn iter_field_lines(
&self,
name: &str,
) -> Option<Box<dyn Iterator<Item = &str> + '_>>
pub fn iter_field_lines( &self, name: &str, ) -> Option<Box<dyn Iterator<Item = &str> + '_>>
Obtain an iterator of lines in the named field.
Sourcepub fn iter_field_comma_delimited(
&self,
name: &str,
) -> Option<Box<dyn Iterator<Item = &str> + '_>>
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.
Sourcepub fn as_str_hash_map(&self) -> HashMap<&str, &str>
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.
Sourcepub fn write<W: Write>(&self, writer: &mut W) -> Result<()>
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>
impl<'a> Clone for BinaryPackageControlFile<'a>
Source§fn clone(&self) -> BinaryPackageControlFile<'a>
fn clone(&self) -> BinaryPackageControlFile<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'cf, 'a: 'cf> DebPackageReference<'cf> for BinaryPackageControlFile<'a>
impl<'cf, 'a: 'cf> DebPackageReference<'cf> for BinaryPackageControlFile<'a>
Source§fn deb_digest(&self, checksum: ChecksumType) -> Result<ContentDigest>
fn deb_digest(&self, checksum: ChecksumType) -> Result<ContentDigest>
Source§fn control_file_for_packages_index(
&self,
) -> Result<BinaryPackageControlFile<'cf>>
fn control_file_for_packages_index( &self, ) -> Result<BinaryPackageControlFile<'cf>>
Source§impl<'a> Debug for BinaryPackageControlFile<'a>
impl<'a> Debug for BinaryPackageControlFile<'a>
Source§impl<'a> Deref for BinaryPackageControlFile<'a>
impl<'a> Deref for BinaryPackageControlFile<'a>
Source§impl<'a> DerefMut for BinaryPackageControlFile<'a>
impl<'a> DerefMut for BinaryPackageControlFile<'a>
Source§impl<'a> From<BinaryPackageControlFile<'a>> for ControlParagraph<'a>
impl<'a> From<BinaryPackageControlFile<'a>> for ControlParagraph<'a>
Source§fn from(cf: BinaryPackageControlFile<'a>) -> Self
fn from(cf: BinaryPackageControlFile<'a>) -> Self
Source§impl<'a> From<ControlParagraph<'a>> for BinaryPackageControlFile<'a>
impl<'a> From<ControlParagraph<'a>> for BinaryPackageControlFile<'a>
Source§fn from(paragraph: ControlParagraph<'a>) -> Self
fn from(paragraph: ControlParagraph<'a>) -> Self
Source§impl<'a> Hash for BinaryPackageControlFile<'a>
impl<'a> Hash for BinaryPackageControlFile<'a>
Source§impl<'a> Ord for BinaryPackageControlFile<'a>
impl<'a> Ord for BinaryPackageControlFile<'a>
Source§fn cmp(&self, other: &BinaryPackageControlFile<'a>) -> Ordering
fn cmp(&self, other: &BinaryPackageControlFile<'a>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a> PartialEq for BinaryPackageControlFile<'a>
impl<'a> PartialEq for BinaryPackageControlFile<'a>
Source§fn eq(&self, other: &BinaryPackageControlFile<'a>) -> bool
fn eq(&self, other: &BinaryPackageControlFile<'a>) -> bool
self and other values to be equal, and is used by ==.Source§impl<'a> PartialOrd for BinaryPackageControlFile<'a>
impl<'a> PartialOrd for BinaryPackageControlFile<'a>
impl<'a> Eq for BinaryPackageControlFile<'a>
impl<'a> StructuralPartialEq for BinaryPackageControlFile<'a>
Auto Trait Implementations§
impl<'a> Freeze for BinaryPackageControlFile<'a>
impl<'a> RefUnwindSafe for BinaryPackageControlFile<'a>
impl<'a> Send for BinaryPackageControlFile<'a>
impl<'a> Sync for BinaryPackageControlFile<'a>
impl<'a> Unpin for BinaryPackageControlFile<'a>
impl<'a> UnwindSafe for BinaryPackageControlFile<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.