ReleaseFile

Struct ReleaseFile 

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

A Debian repository Release file.

Release files contain metadata and list the index files for a repository. They are effectively the entrypoint for defining a Debian repository and its content.

Instances are wrappers around a ControlParagraph. Deref and DerefMut are implemented to allow obtaining the inner ControlParagraph. From and Into are implemented to allow cheap type coercions. Note that converting from ReleaseFile to ControlParagraph may discard PGP cleartext signature data.

Implementations§

Source§

impl<'a> ReleaseFile<'a>

Source

pub fn from_reader<R: BufRead>(reader: R) -> Result<Self>

Construct an instance by reading data from a reader.

The source must be a Debian control file with exactly 1 paragraph.

The source must not be PGP armored. i.e. do not feed it raw InRelease files that begin with -----BEGIN PGP SIGNED MESSAGE-----.

Source

pub fn from_armored_reader<R: BufRead>(reader: R) -> Result<Self>

Construct an instance by reading data from a reader containing a PGP cleartext signature.

This can be used to parse content from an InRelease file, which begins with -----BEGIN PGP SIGNED MESSAGE-----.

An error occurs if the PGP cleartext file is not well-formed or if a PGP parsing error occurs.

The PGP signature is NOT validated. The file will be parsed despite lack of signature verification. This is conceptually insecure. But since Rust has memory safety, some risk is prevented.

Source

pub fn signatures(&self) -> Option<&CleartextSignatures>

Obtain PGP signatures from this InRelease file.

Source

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

Description of this repository.

Source

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

Origin of the repository.

Source

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

Label for the repository.

Source

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

Version of this repository.

Typically a sequence of . delimited integers.

Source

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

Suite of this repository.

e.g. stable, unstable, experimental.

Source

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

Codename of this repository.

Source

pub fn components(&self) -> Option<Box<dyn Iterator<Item = &str> + '_>>

Names of components within this repository.

These are areas within the repository. Values may contain path characters. e.g. main, updates/main.

Source

pub fn architectures(&self) -> Option<Box<dyn Iterator<Item = &str> + '_>>

Debian machine architectures supported by this repository.

e.g. all, amd64, arm64.

Source

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

Time the release file was created, as its raw string value.

Source

pub fn date(&self) -> Option<Result<DateTime<Utc>>>

Time the release file was created, as a DateTime.

The timezone from the original file is always normalized to UTC.

Source

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

Time the release file should be considered expired by the client, as its raw string value.

Source

pub fn valid_until(&self) -> Option<Result<DateTime<Utc>>>

Time the release file should be considered expired by the client.

Source

pub fn not_automatic(&self) -> Option<bool>

Evaluated value for NotAutomatic field.

true is returned iff the value is yes. no and other values result in false.

Source

pub fn but_automatic_upgrades(&self) -> Option<bool>

Evaluated value for ButAutomaticUpgrades field.

true is returned iff the value is yes. no and other values result in false.

Source

pub fn acquire_by_hash(&self) -> Option<bool>

Whether to acquire files by hash.

Source

pub fn iter_index_files( &self, checksum: ChecksumType, ) -> Option<Box<dyn Iterator<Item = Result<ReleaseFileEntry<'_>>> + '_>>

Obtain indexed files in this repository.

Files are grouped by their checksum variant.

If the specified checksum variant is present, Some is returned.

The returned iterator emits ReleaseFileEntry instances. Entries are lazily parsed as they are consumed from the iterator. Parse errors result in an Err.

Source

pub fn iter_classified_index_files( &self, checksum: ChecksumType, ) -> Option<Box<dyn Iterator<Item = Result<ClassifiedReleaseFileEntry<'_>>> + '_>>

Obtain indexed files in this repository classified to their type.

This is like Self::iter_index_files() except it attempts classify each ReleaseFileEntry into a well-defined file type, returning a ClassifiedReleaseFileEntry.

If an entry doesn’t map to a more well-defined type, ClassifiedReleaseFileEntry::Other will be emitted. If an error occurs when coercing an entry to its stronger type, Err will be emitted instead of ClassifiedReleaseFileEntry::Other.

Source

pub fn iter_contents_indices( &self, checksum: ChecksumType, ) -> Option<Box<dyn Iterator<Item = Result<ContentsFileEntry<'_>>> + '_>>

Obtain Contents indices entries given a checksum flavor.

This essentially looks for Contents* files in the file lists.

The emitted entries have component and architecture values derived by the file paths. These values are not checked against the list of components and architectures defined by this file.

Source

pub fn iter_packages_indices( &self, checksum: ChecksumType, ) -> Option<Box<dyn Iterator<Item = Result<PackagesFileEntry<'_>>> + '_>>

Obtain Packages indices entries given a checksum flavor.

This essentially looks for Packages* files in the file lists.

The emitted entries have component and architecture values derived by the file paths. These values are not checked against the list of components and architectures defined by this file.

Source

pub fn find_packages_indices( &self, checksum: ChecksumType, compression: Compression, component: &str, arch: &str, is_installer: bool, ) -> Option<PackagesFileEntry<'_>>

Find a PackagesFileEntry given search constraints.

Source

pub fn iter_sources_indices( &self, checksum: ChecksumType, ) -> Option<Box<dyn Iterator<Item = Result<SourcesFileEntry<'_>>> + '_>>

Obtain Sources indices entries given a checksum flavor.

This essentially looks for Sources* files in the file lists.

Source

pub fn find_sources_indices( &self, checksum: ChecksumType, compression: Compression, component: &str, ) -> Option<SourcesFileEntry<'_>>

Find a SourcesFileEntry given search constraints.

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> Deref for ReleaseFile<'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 ReleaseFile<'a>

Source§

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

Mutably dereferences the value.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

fn from(release: ReleaseFile<'a>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for ReleaseFile<'a>

§

impl<'a> RefUnwindSafe for ReleaseFile<'a>

§

impl<'a> Send for ReleaseFile<'a>

§

impl<'a> Sync for ReleaseFile<'a>

§

impl<'a> Unpin for ReleaseFile<'a>

§

impl<'a> UnwindSafe for ReleaseFile<'a>

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> 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, 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