Skip to content

Conversation

@matthiasbeyer
Copy link

@matthiasbeyer matthiasbeyer commented Jan 5, 2020

This is helpful if the user of the Email object does not know which headers exist.

Copy link
Owner

@afrantzis afrantzis left a comment

Choose a reason for hiding this comment

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

Thanks for the patch! Adding such a function makes sense. I suggest we go with the following name (to match RFC terminology) and signature (to hide implementation details):

pub fn header_field_names(&self) -> Vec<&str>

Also, could you please add a doc comment and test (see tests/test_fields.rs) for this?

@matthiasbeyer
Copy link
Author

If you're fine with the changes I'll fixup-rebase 😄

Copy link
Owner

@afrantzis afrantzis left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Besides a small test improvement (see inline comment), looks good.

email.header_field_names()
.iter()
.all(|name| email.header_field(name).is_some())
);
Copy link
Owner

Choose a reason for hiding this comment

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

We also need to check that what's returned by header_field_names is exhaustive (i.e., all field names present in the email are included).

Copy link
Author

Choose a reason for hiding this comment

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

Doesn't the assertion do this? I mean, if one header_field_name is NOne when asking for header_field(header_field_name), that assert fails, right?

Copy link
Owner

Choose a reason for hiding this comment

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

The current assertion correctly checks that all names returned by header_field_names() are proper/present field names, but not that these names are the full list of names present in the email. For example, if the header contains "To", "Cc", "From" fields, but due to some bug header_field_names() returns only "To" and "Cc", this test will still pass.

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