Better handling of invalid properties.

main
Mauro D 2023-04-27 12:25:11 +00:00
parent be63232d4c
commit c8d672057e
3 changed files with 9 additions and 2 deletions

View File

@ -1,3 +1,8 @@
jmap-client 0.3.0
================================
- Set timeouts using `Duration` instead of `u64`.
- SetError handling of unknown properties.
jmap-client 0.2.1 jmap-client 0.2.1
================================ ================================
- Using maybe_async to reduce duplicate code. - Using maybe_async to reduce duplicate code.

View File

@ -1,7 +1,7 @@
[package] [package]
name = "jmap-client" name = "jmap-client"
description = "JMAP client library for Rust" description = "JMAP client library for Rust"
version = "0.2.1" version = "0.3.0"
edition = "2021" edition = "2021"
authors = [ "Stalwart Labs Ltd. <hello@stalw.art>"] authors = [ "Stalwart Labs Ltd. <hello@stalw.art>"]
license = "Apache-2.0 OR MIT" license = "Apache-2.0 OR MIT"

View File

@ -323,6 +323,7 @@ pub enum Property {
HasAttachment, HasAttachment,
Preview, Preview,
Header(Header), Header(Header),
Other(String),
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@ -386,7 +387,7 @@ impl Property {
"attachments" => Some(Property::Attachments), "attachments" => Some(Property::Attachments),
"bodyStructure" => Some(Property::BodyStructure), "bodyStructure" => Some(Property::BodyStructure),
_ if value.starts_with("header:") => Some(Property::Header(Header::parse(value)?)), _ if value.starts_with("header:") => Some(Property::Header(Header::parse(value)?)),
_ => None, _ => Some(Property::Other(value.to_string())),
} }
} }
} }
@ -420,6 +421,7 @@ impl Display for Property {
Property::HasAttachment => write!(f, "hasAttachment"), Property::HasAttachment => write!(f, "hasAttachment"),
Property::Preview => write!(f, "preview"), Property::Preview => write!(f, "preview"),
Property::Header(header) => header.fmt(f), Property::Header(header) => header.fmt(f),
Property::Other(other) => write!(f, "{}", other),
} }
} }
} }