Derives a [`SourceInfoSchema`] from a string slice containing SRCINFO data. Since the SRCINFO format is only covered by a single version and it not carrying any version information, this function checks whether `s` contains at least the sections `pkgbase` and `pkgname` and the keywords `pkgver` and `pkgrel`. # Examples ``` use alpm_common::FileFormatSchema; use alpm_srcinfo::SourceInfoSchema; u
(s: &str)
| 113 | /// |
| 114 | /// Returns an error if `s` cannot be parsed. |
| 115 | fn derive_from_str(s: &str) -> Result<SourceInfoSchema, Error> { |
| 116 | let _parsed = SourceInfoContent::parser |
| 117 | // A temporary fix for <https://github.com/winnow-rs/winnow/issues/847> |
| 118 | .parse(s.replace('\t', " ").as_str()) |
| 119 | .map_err(|err| Error::ParseError(format!("{err}")))?; |
| 120 | |
| 121 | Ok(SourceInfoSchema::V1(SchemaVersion::new(Version::new( |
| 122 | 1, 0, 0, |
| 123 | )))) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | impl Default for SourceInfoSchema { |