#[non_exhaustive]pub struct WithMetadata<C> {
pub base: C,
pub metadata_exists: Option<String>,
pub private_metadata_exists: Option<String>,
pub metadata_text_contains: Option<MetadataTextMatch>,
pub private_metadata_text_contains: Option<MetadataTextMatch>,
pub metadata_text_equals: Option<MetadataTextMatch>,
pub private_metadata_text_equals: Option<MetadataTextMatch>,
}Expand description
A per-type FilterCondition extended with the six
draft-ietf-jmap-metadata-04 §3.6 condition fields.
§3.6: “For each data type listed in dataTypes, the FilterCondition
object for Foo/query is extended with the optional fields defined
below.” base is the data type’s own condition (for example
jmap_mail_types::EmailSubmissionFilterCondition; the Email and
Mailbox conditions in jmap_mail_types, the Chat, Message and Space
conditions in jmap_chat_types, the CalendarEvent condition in
jmap_calendars_types, the Task condition in jmap_tasks_types, the
ContactCard condition in jmap_contacts_types and the FileNode
condition in jmap_filenode_types already carry the six fields, so they need no wrapper); its fields are
flattened into the same JSON object as the metadata fields. Use it as
the leaf of a jmap_types::Filter<WithMetadata<C>> and pass that
to the extension client’s /query or /queryChanges method; the
conditions compose with AND / OR / NOT as usual (§3.6, RFC 8620
§5.5).
§Serialize only
This type is a client-side request builder. It does not implement
Deserialize: #[serde(flatten)] cannot be combined with
#[serde(deny_unknown_fields)], and decoding a filter without that
check lets a misspelt key decode as a match-all condition (see the
jmap_types::Filter rustdoc).
§Example
use jmap_metadata_types::{MetadataTextMatch, WithMetadata};
#[derive(Default, serde::Serialize)]
#[serde(rename_all = "camelCase")]
struct EmailCond {
in_mailbox: Option<String>,
}
let mut cond = WithMetadata::<EmailCond>::default();
cond.base.in_mailbox = Some("MB-inbox".into());
cond.private_metadata_text_contains =
Some(MetadataTextMatch::new("acme.example.com/memo", "follow up"));
assert_eq!(
serde_json::to_value(&cond).unwrap(),
serde_json::json!({
"inMailbox": "MB-inbox",
"privateMetadataTextContains": {
"path": "acme.example.com/memo",
"value": "follow up"
}
})
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.base: CThe data type’s own filter condition.
metadata_exists: Option<String>Matches if a value is present at this path in the object’s
metadata. The path has the MetadataTextMatch::path syntax.
private_metadata_exists: Option<String>As metadata_exists, but against the authenticated user’s
privateMetadata.
metadata_text_contains: Option<MetadataTextMatch>Substring match under the i;unicode-casemap collation
(RFC 5051) on the
metadata string at a path (draft-ietf-jmap-metadata-04 §3.6).
private_metadata_text_contains: Option<MetadataTextMatch>As metadata_text_contains, but against privateMetadata.
metadata_text_equals: Option<MetadataTextMatch>Exact match on the metadata string at a path, comparing Unicode
code points without case folding or normalization
(draft-ietf-jmap-metadata-04 §3.6).
private_metadata_text_equals: Option<MetadataTextMatch>As metadata_text_equals, but against privateMetadata.