Skip to main content

I18nProjection

Struct I18nProjection 

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

How a Foo/get handler returns locale and localizations (draft-atwood-jmap-updates-00 §3, §4.2.1).

Build one per request with I18nProjection::from_args, ask the backend for I18nProjection::backend_properties, then call I18nProjection::apply on every returned object before filtering it to the requested properties. handle_get and handle_get_with_metadata do all three; a type-specific /get handler calls them itself.

Implementations§

Source§

impl I18nProjection

Source

pub fn from_args<O: JmapObject>( args: &mut Map<String, Value>, using: &[String], info: Option<&I18nInfo>, ) -> Result<Self, JmapError>

Read and remove the language argument of a Foo/get, Foo/query or Foo/queryChanges for type O.

using is the request’s capability list and info the account’s JmapAccounts::i18n_info. A missing or null language is the default and always accepted.

§Errors

invalidArguments when language is non-null and O has no localizable properties, urn:ietf:params:jmap:i18n is not in using, the account does not support it (§3: “as it would any unknown argument”), or the value is not an array of RFC 4647 language ranges.

Source

pub fn without_language<O: JmapObject>( using: &[String], info: Option<&I18nInfo>, ) -> Self

The projection for a request with no language argument (or a null one): what Self::from_args returns for arguments without language, which never fails.

For a handler that does not take language, or that has already removed it. using and info are as for Self::from_args.

Source

pub fn language(&self) -> Option<&[LanguageRange]>

The language ranges, when the request set them.

Source

pub fn backend_properties( &self, requested: Option<&[String]>, ) -> Option<Vec<String>>

The properties to ask the backend for, given the client’s requested list: the view needs locale and localizations even when the client did not ask for them. None (all properties) stays None.

Source

pub fn apply(&self, item: &mut Map<String, Value>)

Shape locale and localizations on one serialized object.

Without the capability in use they are removed. With it, an absent one is returned as null (its default, §4.1), and with language set the object becomes its single-language view (localized_view). state is not affected (§4.2.1).

Trait Implementations§

Source§

impl Clone for I18nProjection

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 Debug for I18nProjection

Source§

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

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

impl Default for I18nProjection

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> 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> ErasedDestructor for T
where T: 'static,

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