Skip to main content

WithMetadata

Struct WithMetadata 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§base: C

The 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.

Trait Implementations§

Source§

impl<C: Clone> Clone for WithMetadata<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug> Debug for WithMetadata<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: Default> Default for WithMetadata<C>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<C: Eq> Eq for WithMetadata<C>

Source§

impl<C: PartialEq> PartialEq for WithMetadata<C>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<C> Serialize for WithMetadata<C>
where C: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<C: PartialEq> StructuralPartialEq for WithMetadata<C>

Auto Trait Implementations§

§

impl<C> Freeze for WithMetadata<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for WithMetadata<C>
where C: RefUnwindSafe,

§

impl<C> Send for WithMetadata<C>
where C: Send,

§

impl<C> Sync for WithMetadata<C>
where C: Sync,

§

impl<C> Unpin for WithMetadata<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for WithMetadata<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for WithMetadata<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.