Parses a SRCINFO file's content into a [`SourceInfoV1`] struct. # Error This function returns two types of errors. 1. An [`Error`] is returned if the input is, for example, invalid UTF-8 or if the input SRCINFO file couldn't be parsed due to invalid syntax. 2. An [`Error`] is returned if the parsed data is incomplete or otherwise invalid. ```rust use alpm_srcinfo::SourceInfoV1; use alpm_types::
(content: &str)
| 170 | /// # } |
| 171 | /// ``` |
| 172 | pub fn from_string(content: &str) -> Result<SourceInfoV1, Error> { |
| 173 | // A temporary fix for <https://github.com/winnow-rs/winnow/issues/847> |
| 174 | let content_no_tabs = content.replace('\t', " "); |
| 175 | |
| 176 | // Parse the given srcinfo content. |
| 177 | let parsed = SourceInfoContent::parser |
| 178 | .parse(content_no_tabs.as_str()) |
| 179 | .map_err(|err| Error::ParseError(format!("{err}")))?; |
| 180 | |
| 181 | // Bring it into a proper structural representation |
| 182 | let source_info = SourceInfoV1::from_raw(parsed)?; |
| 183 | |
| 184 | Ok(source_info) |
| 185 | } |
| 186 | |
| 187 | /// Reads raw [`SourceInfoContent`] from a first parsing step and converts it into a |
| 188 | /// [`SourceInfoV1`]. |