Skip to main content

JmapHandler

Trait JmapHandler 

Source
pub trait JmapHandler<CallerCtx>: Send + Sync {
    // Required method
    fn call(
        &self,
        method: String,
        call_id: String,
        args: Value,
        caller: CallerCtx,
    ) -> HandlerFuture;
}
Expand description

Implement this for each JMAP method handler.

CallerCtx is whatever your auth layer produces — an Identity, a session token, (), etc. The dispatcher passes it through unchanged.

§/set response contract

Handlers for /set methods (RFC 8620 §5.3) that create objects MUST include an "id" field (type string) in each entry of the "created" map. The dispatcher reads this field to accumulate createdIds in the response. Entries without an "id" field are silently skipped — the dispatcher cannot retroactively error a method call that already returned success.

Required Methods§

Source

fn call( &self, method: String, call_id: String, args: Value, caller: CallerCtx, ) -> HandlerFuture

method is the registered method name for this call. A single handler instance may be registered under multiple names (e.g. both "Foo/get" and "Bar/get"); this parameter lets the handler distinguish between them.

call_id is the client-supplied identifier for this invocation (RFC 8620 §3.3). Handlers may use it for logging or correlation but need not echo it — the dispatcher echoes it in the response automatically.

Both parameters are String (not &str) because the returned future is 'static — it must own all data it captures. Handlers that do not need method/call_id can ignore them; handlers that do (e.g. echo) simply capture the owned value.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<B: Send + Sync + 'static, C: Clone + Send + 'static> JmapHandler<C> for ClosureHandler<B, C>