Reads all metadata from an [alpm-package] file. This method reads all the metadata entries in the package file and returns a [`Metadata`] struct containing the processed data. # Errors Returns an error if - reading the metadata entries fails, - parsing a metadata entry fails, - or if any of the required metadata files are not found in the package. [alpm-package]: https://alpm.archlinux.page/s
(&mut self)
| 834 | /// |
| 835 | /// [alpm-package]: https://alpm.archlinux.page/specifications/alpm-package.7.html |
| 836 | pub fn metadata(&mut self) -> Result<Metadata, crate::Error> { |
| 837 | let mut pkginfo = None; |
| 838 | let mut buildinfo = None; |
| 839 | let mut mtree = None; |
| 840 | for entry in self.metadata_entries()? { |
| 841 | match entry? { |
| 842 | MetadataEntry::PackageInfo(m) => pkginfo = Some(m), |
| 843 | MetadataEntry::BuildInfo(m) => buildinfo = Some(m), |
| 844 | MetadataEntry::Mtree(m) => mtree = Some(m), |
| 845 | } |
| 846 | } |
| 847 | Ok(Metadata { |
| 848 | pkginfo: pkginfo.ok_or(crate::Error::MetadataFileNotFound { |
| 849 | name: MetadataFileName::PackageInfo, |
| 850 | })?, |
| 851 | buildinfo: buildinfo.ok_or(crate::Error::MetadataFileNotFound { |
| 852 | name: MetadataFileName::BuildInfo, |
| 853 | })?, |
| 854 | mtree: mtree.ok_or(crate::Error::MetadataFileNotFound { |
| 855 | name: MetadataFileName::Mtree, |
| 856 | })?, |
| 857 | }) |
| 858 | } |
| 859 | |
| 860 | /// Reads the data of a specific metadata file from the [alpm-package] file. |
| 861 | /// |