Expand description
jmap-metadata-client — JMAP Object Metadata extension client helpers.
Implements the client-side helpers for draft-ietf-jmap-metadata-04.
§Architecture change from -01 to -02
The -02 revision eliminates the standalone Metadata object type.
Metadata becomes metadata and privateMetadata properties on
each listed JMAP data type. Clients read and write metadata
through the existing Foo/get, Foo/set, Foo/changes, and
Foo/query methods — there are no separate Metadata/* methods.
This crate no longer provides a SessionClient or method bindings.
Instead, it provides pure helper functions that consumers use
alongside their existing extension-client crate calls:
- Property constants —
METADATA_PROPERTY,PRIVATE_METADATA_PROPERTYfor inclusion in/getpropertieslists. - Filter-condition builders —
metadata_exists_condition,metadata_text_contains_condition,metadata_text_equals_condition, and theirprivate_metadata_*counterparts, producing JSON values suitable for merging into per-typeFilterConditionobjects. /changeshelpers —IGNORE_METADATA_ONLY_CHANGESarg name,is_metadata_property,is_metadata_only_changefor classifyingupdatedPropertiesin/changesresponses.
All functions are stateless and operate on string/JSON values.
§Migration from -01
The -01 crate exposed JmapMetadataExt, SessionClient,
metadata_get, metadata_set, metadata_changes, metadata_query,
metadata_query_changes, five *Params structs, and MetadataChangesParams.
All of those are removed in -02. Extension-client crates that previously
depended on this crate for standalone Metadata/* methods should instead
use the helper functions from this crate alongside their own typed method
calls (e.g. email_get with metadata properties, email_query with
metadata filter conditions).
§Example
use jmap_metadata_client::{
METADATA_PROPERTY,
PRIVATE_METADATA_PROPERTY,
metadata_exists_condition,
metadata_text_contains_condition,
};
// Include metadata properties in a /get properties list
let properties = vec!["id", "subject", METADATA_PROPERTY, PRIVATE_METADATA_PROPERTY];
assert!(properties.contains(&"metadata"));
// Build filter conditions for a /query request
let exists = metadata_exists_condition("photography");
assert_eq!(exists, serde_json::json!({ "metadataExists": "photography" }));
let text_match = metadata_text_contains_condition("photography/caption", "sunset");
assert_eq!(text_match, serde_json::json!({
"metadataTextContains": { "path": "photography/caption", "value": "sunset" }
}));Constants§
- IGNORE_
METADATA_ ONLY_ CHANGES - Wire name of the
ignoreMetadataOnlyChangesargument for/changesrequests (draft-ietf-jmap-metadata-04 §3.3). - METADATA_
PROPERTY - Wire name of the shared metadata property on listed data types (§2).
- PRIVATE_
METADATA_ PROPERTY - Wire name of the per-user private metadata property on listed data types (§2).
Functions§
- is_
metadata_ only_ change - Returns
trueif ALL properties inupdated_propertiesare metadata properties (draft-ietf-jmap-metadata-04 §3.3). - is_
metadata_ property - Returns
trueifpropertyis one of the metadata-extension properties (metadataorprivateMetadata). - metadata_
exists_ condition - Build a
metadataExistsfilter condition (§3.6). - metadata_
text_ contains_ condition - Build a
metadataTextContainsfilter condition (§3.6). - metadata_
text_ equals_ condition - Build a
metadataTextEqualsfilter condition (§3.6). - private_
metadata_ exists_ condition - Build a
privateMetadataExistsfilter condition (§3.6). - private_
metadata_ text_ contains_ condition - Build a
privateMetadataTextContainsfilter condition (§3.6). - private_
metadata_ text_ equals_ condition - Build a
privateMetadataTextEqualsfilter condition (§3.6).