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

Fix deserialize #93

Merged
merged 2 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ pub struct Message<'x> {
pub attachments: Vec<MessagePartId>,

#[cfg_attr(feature = "serde_support", serde(default))]
#[cfg_attr(feature = "serde_support", serde(borrow))]
pub parts: Vec<MessagePart<'x>>,

#[cfg_attr(feature = "serde_support", serde(skip))]
Expand All @@ -295,7 +294,6 @@ pub struct MessagePart<'x> {
pub headers: Vec<Header<'x>>,
pub is_encoding_problem: bool,
#[cfg_attr(feature = "serde_support", serde(default))]
#[cfg_attr(feature = "serde_support", serde(borrow))]
pub body: PartType<'x>,
#[cfg_attr(feature = "serde_support", serde(skip))]
pub encoding: Encoding,
Expand Down Expand Up @@ -345,11 +343,9 @@ pub enum PartType<'x> {
Html(Cow<'x, str>),

/// Any other part type that is not text.
#[cfg_attr(feature = "serde_support", serde(borrow))]
Binary(Cow<'x, [u8]>),

/// Any inline binary data that.
#[cfg_attr(feature = "serde_support", serde(borrow))]
InlineBinary(Cow<'x, [u8]>),

/// Nested RFC5322 message.
Expand Down
3 changes: 3 additions & 0 deletions src/parsers/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ mod tests {
let message = MessageParser::default().parse(&raw_message).unwrap();
let json_message = serde_json::to_string_pretty(&message).unwrap();

// Test that deserialization also works
let _: super::Message<'_> = serde_json::from_str(&json_message).unwrap();

if json_message.as_bytes() != expected_result {
file_name.set_extension("failed");
fs::write(&file_name, json_message.as_bytes()).unwrap();
Expand Down
Loading