Skip to content

Conversation

@JayceFayne
Copy link

@JayceFayne JayceFayne commented Jan 29, 2026

The goal of this PR was to parse embedded rfc822 messages (eagerly).
For example:

From: sender@example.com
To: recipient@example.com
Subject: Wrapper message
MIME-Version: 1.0
Content-Type: message/rfc822

From: sender@example.com
To: recipient@example.com
Subject: Embedded message
MIME-Version: 1.0
Content-Type: text/plain

Hi

Is not being parsed but instead you get a binary body...which is fine.
It turns out adding this feature would just add unneccesarry complexity. I am opening this PR to upstream some refactors that make the parse_mail_recursive function much more readable.

@JayceFayne JayceFayne changed the title ~~eagerly parse embedded messages~~ some refactors to make the code more readable some refactors to make the code more readable Jan 29, 2026
Copy link
Owner

@staktrace staktrace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Overall this is a nice cleanup. I'd prefer to drop the second commit but the other three look good


fn parse_mail_recursive(
raw_data: &[u8],
raw_bytes: &[u8],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer to keep it as raw_data here. Either way it's inconsistent because the public function parse_mail has a parameter raw_data which is passed into this function, and the public struct ParsedMail has a field raw_bytes which is populated from raw_data. So no matter which one you use it's going to be inconsistent one way or the other. However if you think of this library as a data processor, with "raw data" coming and "raw bytes" going out, then this function is still before the conversion, so conceptually is more "raw data" than "raw bytes".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants