DispatchConn

Struct DispatchConn 

Source
pub struct DispatchConn<HandlerCtx, HandlerError: Debug> { /* private fields */ }

Implementations§

Source§

impl<UserData, UserError: Debug> DispatchConn<UserData, UserError>

Source

pub fn new( conn: DuplexConn, ctx: UserData, default_handler: Box<HandleFn<UserData, UserError>>, ) -> Self

Source

pub fn add_handler( &mut self, path: &str, handler: Box<HandleFn<UserData, UserError>>, )

Source

pub fn run( &mut self, ) -> Result<(), (Option<MarshalledMessage>, HandleError<UserError>)>

Endless loop that takes messages and dispatches them to the setup handlers. If any errors occur they will be returned. Depending on the error you may choose to just call this function again. Note that you are expected to send a meaningful error message. The offending message will be returned alongside the error.

This also sends reponses back to the callers, returned by the handlers. If the handlers did return None, it sends a default response with no content.

Auto Trait Implementations§

§

impl<HandlerCtx, HandlerError> Freeze for DispatchConn<HandlerCtx, HandlerError>
where HandlerCtx: Freeze,

§

impl<HandlerCtx, HandlerError> !RefUnwindSafe for DispatchConn<HandlerCtx, HandlerError>

§

impl<HandlerCtx, HandlerError> !Send for DispatchConn<HandlerCtx, HandlerError>

§

impl<HandlerCtx, HandlerError> !Sync for DispatchConn<HandlerCtx, HandlerError>

§

impl<HandlerCtx, HandlerError> Unpin for DispatchConn<HandlerCtx, HandlerError>
where HandlerCtx: Unpin,

§

impl<HandlerCtx, HandlerError> !UnwindSafe for DispatchConn<HandlerCtx, HandlerError>

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.