Improving the representation of RFC8621 groups #112
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The way
mail-parser
currently represents mailboxes and groups is a bit verbose to deal with, and makes subsequent handling more complex and error prone. Because of the arguably awkward way RFC8621 decides to represent single mailboxes #98 as a group by section4.1.2.4 GroupedAddresses
, anybody that does need the fidelity of the addresses parsed as in RFC5322 has to decompose them again.This PR does not advocate changing the representation to RFC5322, instead suggesting more modestly that the enum be abandoned. Because of the awkwardness of RFC8621
GroupedAddresses
users that do match on the enum already must be aware that single mailboxes may have different representations, and have to make sure to handle mailboxes the same whether they are inAddress::List
orAddress::Group
. As an example, we needed the RFC5322 representation for which we used this codeThis exemplifies how the enum is more of a hinderance than a benefit as an API, but the common
Address::List
case does save one allocation overAddress::Group
. This PR removes the enum, focusing on the way this simplifies the API, but we can salvage the allocation if necessary.For reference, this is what the above code would look like after this PR.