the api around custom headers isn't very nice. #741
Unanswered
rwthompsonii
asked this question in
Ideas
Replies: 1 comment
-
Just for added context for newcomers like me, am I understanding correctly this "custom" header API is referring to this usage? : let mut headers = Headers::new();
headers.insert_raw(HeaderValue::new(
HeaderName::new_from_ascii_str("Subject"),
"Sample subject".to_string(),
)); Or the Line 679 in c1d37d5 I was just looking into adding headers from HTML body and attachments, and when I saw multiple ways of solving the problem I wanted to make sure I wasn't missing a better header API (that perhaps you're referring to?) Thanks, good discussion as these sorts of features are a bit off the beaten trail, to a newcomer at least ;) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm writing a converter for email message types -- for instance, from MSG to EML. As a result, I have a requirement to be able to transfer arbitrary email headers from one format to another. I really need to be able to get a mutable reference to the actual headers used, so I can just set them. In the meantime, I'm just forking the repo and exposing the headers from the MessageBuilder as a &mut so that I can be unblocked, but forcing an entire struct definition for every possible header type just isn't a scalable solution. There needs to be a way to say "take this string that I have parsed and stick it in as the key". If you want to validate the correctness in terms of characters, that's fine, but right now I can't figure out how to implement this requirement with this API.
One immediate way to solve this (I think) would be to not require the
name
method onHeader
to be static -- if it was a regular &self method then I could construct an object that matches that trait definition and return the name given it, and then I could just define one custom struct for all headers.Beta Was this translation helpful? Give feedback.
All reactions