pub struct DispatchConn<HandlerCtx, HandlerError: Debug> { /* private fields */ }Implementations§
Source§impl<UserData, UserError: Debug> DispatchConn<UserData, UserError>
impl<UserData, UserError: Debug> DispatchConn<UserData, UserError>
pub fn new( conn: DuplexConn, ctx: UserData, default_handler: Box<HandleFn<UserData, UserError>>, ) -> Self
pub fn add_handler( &mut self, path: &str, handler: Box<HandleFn<UserData, UserError>>, )
Sourcepub fn run(
&mut self,
) -> Result<(), (Option<MarshalledMessage>, HandleError<UserError>)>
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> 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