Skip to main content

CallContext

Struct CallContext 

Source
#[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>, }
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
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.
§method: String

The 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: String

The 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: Value

The call’s arguments, with result references already resolved (RFC 8620 §3.7).

§caller: CallerCtx

Whatever 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-04 §3 extends Foo/changes only for requests whose using includes urn:ietf:params:jmap:metadata.

Implementations§

Source§

impl<CallerCtx> CallContext<CallerCtx>

Source

pub fn new( method: impl Into<String>, call_id: impl Into<String>, args: Value, caller: CallerCtx, ) -> Self

A context for one method call.

Source

pub fn with_created_ids(self, created_ids: BTreeMap<Id, Id>) -> Self

Source

pub fn with_using(self, using: Vec<String>) -> Self

Set CallContext::using; CallContext::new leaves it empty.

Trait Implementations§

Source§

impl<CallerCtx: Clone> Clone for CallContext<CallerCtx>

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<CallerCtx: Debug> Debug for CallContext<CallerCtx>

Source§

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

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

impl<CallerCtx: PartialEq> PartialEq for CallContext<CallerCtx>

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<CallerCtx: PartialEq> StructuralPartialEq for CallContext<CallerCtx>

Auto Trait Implementations§

§

impl<CallerCtx> Freeze for CallContext<CallerCtx>
where CallerCtx: Freeze,

§

impl<CallerCtx> RefUnwindSafe for CallContext<CallerCtx>
where CallerCtx: RefUnwindSafe,

§

impl<CallerCtx> Send for CallContext<CallerCtx>
where CallerCtx: Send,

§

impl<CallerCtx> Sync for CallContext<CallerCtx>
where CallerCtx: Sync,

§

impl<CallerCtx> Unpin for CallContext<CallerCtx>
where CallerCtx: Unpin,

§

impl<CallerCtx> UnsafeUnpin for CallContext<CallerCtx>
where CallerCtx: UnsafeUnpin,

§

impl<CallerCtx> UnwindSafe for CallContext<CallerCtx>
where CallerCtx: 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> 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