Skip to main content

MetadataProjection

Struct MetadataProjection 

Source
pub struct MetadataProjection { /* private fields */ }
Expand description

How a Foo/get handler returns metadata and privateMetadata (draft-ietf-jmap-metadata-04 §2 and §3.1).

Build one per request with MetadataProjection::new, then call MetadataProjection::apply on every returned object.

Implementations§

Source§

impl MetadataProjection

Source

pub fn new( properties: Option<&[String]>, default_includes: bool, using: &[String], info: Option<&DataTypeMetadataInfo>, ) -> Result<Self, JmapError>

Build the projection for one Foo/get request.

properties is the request’s properties (None for the default list), default_includes is false for Email/get, whose “default property list … is unchanged” (-04 §3.1), and true for every other type; info is the type’s DataTypeMetadataInfo (JmapBackend::metadata_info), None when the type is not listed and so “does not gain the metadata or privateMetadata properties” (-04 §1.2.1). The rules:

  • Default list: both properties with the capability in using (“the server MUST include metadata and, where supportsPrivate is true, privateMetadata”), neither without it (“not default properties of Foo/get”) (-04 §3, §3.1).
  • A root name returns the whole property, with or without the capability (“still returned when requested by name”).
  • With the capability, metadata/<namespace> and privateMetadata/<namespace> return only the stored namespaces named; several combine by union and a root entry supersedes them. A namespace with no stored data is left out, which covers “A subselector naming a namespace that is not supported … MUST be silently omitted … unless the object has data stored under that namespace”. Without the capability these entries are ignored like any other unknown property.
  • privateMetadata is never returned when supportsPrivate is false (-04 §2: “this property MUST NOT be returned”).
§Errors

invalidArguments for an entry that begins with metadata/ or privateMetadata/ and is not followed by a namespace identifier (-04 §3.1: “Any other properties entry beginning with metadata/ or privateMetadata/ MUST be rejected with an “invalidArguments” method-level error“).

Source

pub fn apply(&self, source: &Value, target: &mut Value)

Set or remove metadata and privateMetadata on the response object target from the stored object source.

Trait Implementations§

Source§

impl Debug for MetadataProjection

Source§

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

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

impl Default for MetadataProjection

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more