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
impl I18nProjection
Sourcepub fn from_args<O: JmapObject>(
args: &mut Map<String, Value>,
using: &[String],
info: Option<&I18nInfo>,
) -> Result<Self, JmapError>
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.
Sourcepub fn without_language<O: JmapObject>(
using: &[String],
info: Option<&I18nInfo>,
) -> Self
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.
Sourcepub fn language(&self) -> Option<&[LanguageRange]>
pub fn language(&self) -> Option<&[LanguageRange]>
The language ranges, when the request set them.
Sourcepub fn backend_properties(
&self,
requested: Option<&[String]>,
) -> Option<Vec<String>>
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.
Sourcepub fn apply(&self, item: &mut Map<String, Value>)
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).