MCPcopy Create free account
hub / github.com/archlinux/alpm / derive_from_str

Method derive_from_str

alpm-srcinfo/src/schema.rs:115–124  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
127impl Default for SourceInfoSchema {

Callers

nothing calls this directly

Calls 2

parseMethod · 0.80
as_strMethod · 0.45

Tested by

no test coverage detected