Skip to main content

DispatcherHandler

Struct DispatcherHandler 

Source
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>

Source

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.

Source

pub fn with_known_capabilities<I, S>(self, capabilities: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

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>

Source§

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

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

impl<C: Clone + Send + Sync + 'static> RequestHandler for DispatcherHandler<C>

Source§

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)

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>
where Arc<Dispatcher<C>>: Freeze, C: Freeze,

§

impl<C> Move for DispatcherHandler<C>

§

impl<C> Send for DispatcherHandler<C>
where C: Send, Arc<Dispatcher<C>>: Send,

§

impl<C> Sync for DispatcherHandler<C>
where C: Sync, Arc<Dispatcher<C>>: Sync,

§

impl<C> Unpin for DispatcherHandler<C>
where C: Unpin, Arc<Dispatcher<C>>: Unpin,

§

impl<C> UnsafeUnpin for DispatcherHandler<C>

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> ErasedDestructor for T
where T: 'static,

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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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