Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing message prefixes (sources) into an enumeration. #143

Closed
aatxe opened this issue Jul 19, 2018 · 1 comment
Closed

Parsing message prefixes (sources) into an enumeration. #143

aatxe opened this issue Jul 19, 2018 · 1 comment
Labels
enhancement good first issue An issue that would be good for new contributors!

Comments

@aatxe
Copy link
Owner

aatxe commented Jul 19, 2018

This is a relatively small and self-contained task. So, I think it'd be a good first issue for anyone looking for a way to contribute! This should be contributed as part of 0.14.

Currently, Message is defined to use a String for prefixes, but in RFC 2812, the grammar for prefixes is given as prefix = servername / ( nickname [ [ "!" user ] "@" host ] ) which is sufficiently specific to allow for parsing them into an enumeration instead.

This should be probably look something like:

enum Prefix {
    /// servername
    ServerName(String),
    /// nickname [ ["!" username] "@" hostname ]
    Nickname(String, Option<String>, Option<String>),
}

One problem is that in the (probably rare in practice) situation where you are receiving a nickname without a username or hostname attached, there is ambiguity. Most nicknames are also valid server names. However, I think it would be reasonable to classify anything containing a . as a server name and anything else as a nick name. Otherwise, we could add a third option for Ambiguous, but that probably punishes the common case for something that I'm not sure even happens on modern IRCds.

Ramifications

Part of the Message API has some functionality for getting the source nickname and so forth. This API should be cleaned up using this new enum.

@aatxe aatxe added enhancement good first issue An issue that would be good for new contributors! labels Jul 19, 2018
@aatxe
Copy link
Owner Author

aatxe commented Dec 3, 2018

This was implemented in #149.

@aatxe aatxe closed this as completed Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue An issue that would be good for new contributors!
Projects
None yet
Development

No branches or pull requests

1 participant