@@ -2436,7 +2436,9 @@ impl<Req: JsonRpcRequest, Notif: JsonRpcMessage> Dispatch<Req, Notif> {
24362436 }
24372437 }
24382438
2439- pub ( crate ) fn into_handled_no_untyped (
2439+ /// Erase this typed dispatch back to untyped JSON and wrap it in
2440+ /// [`Handled::No`] so the connection loop can offer it to later handlers.
2441+ pub ( crate ) fn erase_into_unhandled (
24402442 self ,
24412443 retry : bool ,
24422444 ) -> Result < Handled < Dispatch > , crate :: Error > {
@@ -2468,24 +2470,6 @@ impl<Req: JsonRpcRequest, Notif: JsonRpcMessage> Dispatch<Req, Notif> {
24682470 }
24692471}
24702472
2471- /// Normalize legacy parse errors from matched incoming request/notification params.
2472- ///
2473- /// `MethodNotFound` still means "this type does not handle the method" and therefore falls
2474- /// through to later handlers. The SDK's own request/notification parsers now return
2475- /// `InvalidParams` directly; this rewrite remains only as a compatibility backstop for older
2476- /// custom parsers that still emit `ParseError`.
2477- fn normalize_incoming_message_parse_error ( err : crate :: Error ) -> Option < crate :: Error > {
2478- match & err. code {
2479- crate :: ErrorCode :: MethodNotFound => None ,
2480- crate :: ErrorCode :: ParseError => {
2481- let mut invalid_params = crate :: Error :: invalid_params ( ) ;
2482- invalid_params. data = err. data ;
2483- Some ( invalid_params)
2484- }
2485- _ => Some ( err) ,
2486- }
2487- }
2488-
24892473/// Outcome of matching an untyped [`Dispatch`] against a request type.
24902474#[ derive( Debug ) ]
24912475pub enum RequestMatch < Req : JsonRpcRequest > {
@@ -2546,12 +2530,9 @@ impl Dispatch {
25462530 if Req :: matches_method ( & message. method ) {
25472531 match Req :: parse_message ( & message. method , & message. params ) {
25482532 Ok ( req) => RequestMatch :: Matched ( req, responder. cast ( ) ) ,
2549- Err ( err) => match normalize_incoming_message_parse_error ( err) {
2550- Some ( error) => RequestMatch :: Rejected {
2551- dispatch : Dispatch :: Request ( message, responder) ,
2552- error,
2553- } ,
2554- None => RequestMatch :: Unhandled ( Dispatch :: Request ( message, responder) ) ,
2533+ Err ( error) => RequestMatch :: Rejected {
2534+ dispatch : Dispatch :: Request ( message, responder) ,
2535+ error,
25552536 } ,
25562537 }
25572538 } else {
@@ -2575,12 +2556,9 @@ impl Dispatch {
25752556 if Notif :: matches_method ( & message. method ) {
25762557 match Notif :: parse_message ( & message. method , & message. params ) {
25772558 Ok ( notif) => NotificationMatch :: Matched ( notif) ,
2578- Err ( err) => match normalize_incoming_message_parse_error ( err) {
2579- Some ( error) => NotificationMatch :: Rejected {
2580- dispatch : Dispatch :: Notification ( message) ,
2581- error,
2582- } ,
2583- None => NotificationMatch :: Unhandled ( Dispatch :: Notification ( message) ) ,
2559+ Err ( error) => NotificationMatch :: Rejected {
2560+ dispatch : Dispatch :: Notification ( message) ,
2561+ error,
25842562 } ,
25852563 }
25862564 } else {
@@ -2599,6 +2577,7 @@ impl Dispatch {
25992577 /// Once the request/notification side matches by method, any parse error is terminal for
26002578 /// that method and yields [`TypedDispatchMatch::Rejected`]. Likewise, a matched response
26012579 /// whose result cannot be decoded is rejected instead of bubbling up as a fatal `Err`.
2580+ #[ must_use]
26022581 pub fn match_typed_dispatch < Req : JsonRpcRequest , Notif : JsonRpcNotification > (
26032582 self ,
26042583 ) -> TypedDispatchMatch < Req , Notif > {
0 commit comments