pub struct Router { /* private fields */ }Expand description
Handlers for incoming requests and notifications, keyed by method.
A request with no handler is answered with
ErrorCode::METHOD_NOT_FOUND; a notification with no handler is
ignored. $/cancel is handled by the connection itself.
Implementations§
Source§impl Router
impl Router
Sourcepub fn request<R, F, Fut>(self, handler: F) -> Self
pub fn request<R, F, Fut>(self, handler: F) -> Self
Handles request R. The handler gets the decoded params and a
Peer for calling back the other side. Params that fail to decode
are answered with ErrorCode::INVALID_PARAMS without calling it.
Sourcepub fn notification<N, F>(self, handler: F) -> Self
pub fn notification<N, F>(self, handler: F) -> Self
Handles notification N. Notification handlers run one at a time, in
arrival order, on the connection’s task, so they should be quick;
spawn a task for slow work. Params that fail to decode are logged and
dropped.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Router
impl !UnwindSafe for Router
impl Forget for Router
impl Freeze for Router
impl Move for Router
impl Send for Router
impl Sync for Router
impl Unpin for Router
impl UnsafeUnpin for Router
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