Skip to main content

Crate jmap_metadata_client

Crate jmap_metadata_client 

Source
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:

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 ignoreMetadataOnlyChanges argument for /changes requests (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 true if ALL properties in updated_properties are metadata properties (draft-ietf-jmap-metadata-04 §3.3).
is_metadata_property
Returns true if property is one of the metadata-extension properties (metadata or privateMetadata).
metadata_exists_condition
Build a metadataExists filter condition (§3.6).
metadata_text_contains_condition
Build a metadataTextContains filter condition (§3.6).
metadata_text_equals_condition
Build a metadataTextEquals filter condition (§3.6).
private_metadata_exists_condition
Build a privateMetadataExists filter condition (§3.6).
private_metadata_text_contains_condition
Build a privateMetadataTextContains filter condition (§3.6).
private_metadata_text_equals_condition
Build a privateMetadataTextEquals filter condition (§3.6).