#[non_exhaustive]pub struct CallContext<CallerCtx> {
pub method: String,
pub call_id: String,
pub args: Value,
pub caller: CallerCtx,
pub created_ids: BTreeMap<Id, Id>,
pub using: Vec<String>,
pub atomic: bool,
}Expand description
Everything Dispatcher::dispatch hands a JmapHandler for one
method call (RFC 8620 §3.2 Invocation, plus the caller).
#[non_exhaustive] so the dispatcher can pass more per-call context
(a deadline, a tracing span, the request’s creation ids) without
breaking every handler (bd:JMAP-wf92.7). Handlers read the public
fields; code that calls a handler directly builds one with
CallContext::new.
Fields are owned because the returned HandlerFuture is
'static.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.method: StringThe registered method name for this call. One handler may be
registered under several names (e.g. "Foo/get" and
"Bar/get"); this tells them apart.
call_id: StringThe client-supplied method call id (RFC 8620 §3.2). The dispatcher echoes it in the response; handlers may use it for logging or correlation.
args: ValueThe call’s arguments, with result references already resolved (RFC 8620 §3.7).
caller: CallerCtxWhatever the auth layer produced, passed to
Dispatcher::dispatch and cloned for each call.
created_ids: BTreeMap<Id, Id>Creation id to server-assigned id for every record created
earlier in this request, plus the client’s initial createdIds
(RFC 8620 §3.3, §5.3). A /set handler resolves #-prefixed
Id-typed values against it with resolve_creation_ref; the
dispatcher cannot, because only the handler knows which
properties are Id-typed (bd:JMAP-8ypy).
using: Vec<String>The request’s using capability URIs (RFC 8620 §3.3). Extensions
change method behaviour per request on it; e.g.
draft-ietf-jmap-metadata-05 §3 extends Foo/changes only for
requests whose using includes urn:ietf:params:jmap:metadata.
atomic: boolThe call is an atomic Foo/set (draft-ietf-jmap-conditional-02 §4):
the dispatcher removed the atomic argument and will commit all of
the method’s changes or none. A handler need not act on it; it is
there for handlers that can fail fast.
Implementations§
Source§impl<CallerCtx> CallContext<CallerCtx>
impl<CallerCtx> CallContext<CallerCtx>
Sourcepub fn new(
method: impl Into<String>,
call_id: impl Into<String>,
args: Value,
caller: CallerCtx,
) -> Self
pub fn new( method: impl Into<String>, call_id: impl Into<String>, args: Value, caller: CallerCtx, ) -> Self
A context for one method call.
Sourcepub fn with_created_ids(self, created_ids: BTreeMap<Id, Id>) -> Self
pub fn with_created_ids(self, created_ids: BTreeMap<Id, Id>) -> Self
Set CallContext::created_ids; CallContext::new leaves it
empty.
Sourcepub fn with_using(self, using: Vec<String>) -> Self
pub fn with_using(self, using: Vec<String>) -> Self
Set CallContext::using; CallContext::new leaves it empty.
Sourcepub fn with_atomic(self, atomic: bool) -> Self
pub fn with_atomic(self, atomic: bool) -> Self
Set CallContext::atomic; CallContext::new leaves it false.