pub struct DispatcherHandler<C> { /* private fields */ }Available on crate feature
server only.Expand description
A RequestHandler that dispatches every Request on a
Dispatcher for one caller.
use std::sync::Arc;
use jmap_websocket::server::DispatcherHandler;
use jmap_websocket::jmap_server::Dispatcher;
use jmap_websocket::jmap_types::State;
let dispatcher: Arc<Dispatcher<()>> = Arc::new(Dispatcher::new());
let handler = DispatcherHandler::new(dispatcher, (), || State::from("s0"))
.with_known_capabilities(["urn:ietf:params:jmap:core"]);Implementations§
Source§impl<C: Clone + Send + Sync + 'static> DispatcherHandler<C>
impl<C: Clone + Send + Sync + 'static> DispatcherHandler<C>
Sourcepub fn new(
dispatcher: Arc<Dispatcher<C>>,
caller: C,
session_state: impl Fn() -> State + Send + Sync + 'static,
) -> Self
pub fn new( dispatcher: Arc<Dispatcher<C>>, caller: C, session_state: impl Fn() -> State + Send + Sync + 'static, ) -> Self
Dispatch on dispatcher as caller (the authenticated principal
of the opening handshake, RFC 8887 §4.1). session_state gives
the Response’s sessionState (RFC 8620 §3.4) at each dispatch.
Sourcepub fn with_known_capabilities<I, S>(self, capabilities: I) -> Self
pub fn with_known_capabilities<I, S>(self, capabilities: I) -> Self
Answer a Request whose using names a capability not in
capabilities with unknownCapability (RFC 8620 §3.3) through
jmap_server::check_known_capabilities. Without this every
using is accepted.
Trait Implementations§
Source§impl<C> Debug for DispatcherHandler<C>
impl<C> Debug for DispatcherHandler<C>
Source§impl<C: Clone + Send + Sync + 'static> RequestHandler for DispatcherHandler<C>
impl<C: Clone + Send + Sync + 'static> RequestHandler for DispatcherHandler<C>
Source§async fn handle(&self, request: JmapRequest) -> Result<JmapResponse, JmapError>
async fn handle(&self, request: JmapRequest) -> Result<JmapResponse, JmapError>
Process one parsed Request.
Err is a request-level error (RFC
8620 §3.6.1, e.g. unknownCapability) and is sent as a
RequestError; method-level errors belong in the Response.Source§fn prepare_problem(&self, problem: &mut ProblemDetails)
fn prepare_problem(&self, problem: &mut ProblemDetails)
Called on every RequestError before it is sent, including those
the driver makes itself. Set a localized
title here (RFC 9457
§3.1.3); the default leaves the problem as it is.Auto Trait Implementations§
impl<C> !RefUnwindSafe for DispatcherHandler<C>
impl<C> !UnwindSafe for DispatcherHandler<C>
impl<C> Forget for DispatcherHandler<C>
impl<C> Freeze for DispatcherHandler<C>
impl<C> Move for DispatcherHandler<C>
impl<C> Send for DispatcherHandler<C>
impl<C> Sync for DispatcherHandler<C>
impl<C> Unpin for DispatcherHandler<C>
impl<C> UnsafeUnpin for DispatcherHandler<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more