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

Method parser

alpm-types/src/openpgp.rs:449–468  ·  view source on GitHub ↗

Parses a [`Packager`] from a string slice. Consumes all of its input. # Examples See [`Self::from_str`] for code examples. # Errors Returns an error if `input` does not represent a valid [`Packager`].

(input: &mut &str)

Source from the content-addressed store, hash-verified

447impl ParserUntil for Packager {
448 /// Parses a [`Packager`] from a string slice.
449 ///
450 /// # Errors
451 ///
452 /// Returns an error if `input` does not represent a valid [`Packager`].
453 fn parser_until<'a, P>(delimiter: P) -> impl Parser<Input<'a>, Self, ErrMode<ParseStack<'a>>>
454 where
455 P: Parser<Input<'a>, &'a str, ErrMode<ParseStack<'a>>>,
456 {
457 // Define the actual parser closure.
458 // The delimiter is moved into the closure and borrowed via `by_ref()` on each call.
459 let mut delimiter_parser = delimiter;
460 let parser = move |input: &mut Input<'a>| -> PResult<'a, Self> {
461 // This format is a bit opaque and may include leading whitespaces.
462 // Consume any of those so we don't have to guess about them later on.
463 space0.parse_next(input)?;
464
465 // Make sure the first character isn't a `<`, which may happen if the packager name is
466 // missing.
467 not("<")
468 .expected_text("a packager name")
469 .parse_next(input)?;
470
471 // The name that precedes the email address

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected