Module rama::username

Expand description

Utilities to work with usernames and pull information out of it.

§Username Parsing

The parse_username function is used to parse a username and extract information from its labels. The function takes a parser, which is used to parse the labels from the username.

The parser is expected to implement the UsernameLabelParser trait, which has two methods:

  • parse_label: This method is called for each label in the username, and is expected to return whether the label was used or ignored.
  • build: This method is called after all labels have been parsed, and is expected to consume the parser and store any relevant information.

The parser can be a single parser or a tuple of parsers. Tuple parsers all receive all labels, unless wrapped by a ExclusiveUsernameParsers, in which case the first parser that consumes a label will stop the iteration over the parsers.

Parsers are to return UsernameLabelState::Used in case they consumed the label, and UsernameLabelState::Ignored in case they did not. This way the parser-caller (e.g. parse_username) can decide whether to fail on ignored labels.

§Username Composing

Composing a username is the opposite of “Username Parsing”, and is used to suffix labels to a username.

Structs§

Enums§

Constants§

Traits§

Functions§