33//! When handling [`UntypedMessage`]s, you can use [`MatchMessage`] for simple parsing
44//! or [`MatchMessageFrom`] when you need role-aware endpoint transforms (e.g., unwrapping
55//! proxy envelopes).
6+ //!
7+ //! # When to use which
8+ //!
9+ //! - **[`MatchMessageFrom`]**: Preferred over implementing [`JrMessageHandler`] directly.
10+ //! Use this in connection handlers when you need to match on message types with
11+ //! proper endpoint-aware transforms (e.g., unwrapping `SuccessorMessage` envelopes).
12+ //!
13+ //! - **[`MatchMessage`]**: Use this when you already have an unwrapped message and
14+ //! just need to parse it, such as inside a [`MatchMessageFrom`] callback or when
15+ //! processing messages that don't need endpoint transforms.
16+ //!
17+ //! [`JrMessageHandler`]: crate::JrMessageHandler
618
719// Types re-exported from crate root
820use jsonrpcmsg:: Params ;
@@ -16,9 +28,12 @@ use crate::{
1628
1729/// Role-agnostic helper for pattern-matching on untyped JSON-RPC messages.
1830///
19- /// Use this when you just need to parse messages as specific types without
20- /// any endpoint-aware transforms. For role-aware matching that handles
21- /// proxy envelope unwrapping, use [`MatchMessageFrom`] instead.
31+ /// Use this when you already have an unwrapped message and just need to parse it,
32+ /// such as inside a [`MatchMessageFrom`] callback or when processing messages
33+ /// that don't need endpoint transforms.
34+ ///
35+ /// For connection handlers where you need proper endpoint-aware transforms,
36+ /// use [`MatchMessageFrom`] instead.
2237///
2338/// # Example
2439///
@@ -249,13 +264,19 @@ impl MatchMessage {
249264
250265/// Role-aware helper for pattern-matching on untyped JSON-RPC requests.
251266///
267+ /// **Prefer this over implementing [`JrMessageHandler`] directly.** This provides
268+ /// a more ergonomic API for matching on message types in connection handlers.
269+ ///
252270/// Use this when you need endpoint-aware transforms (e.g., unwrapping proxy envelopes)
253- /// before parsing messages. For simple parsing without role awareness, use [`MatchMessage`].
271+ /// before parsing messages. For simple parsing without role awareness (e.g., inside
272+ /// a callback), use [`MatchMessage`] instead.
254273///
255274/// This wraps [`MatchMessage`] and applies endpoint-specific message transformations
256275/// via `remote_style().handle_incoming_message()` before delegating to `MatchMessage`
257276/// for the actual parsing.
258277///
278+ /// [`JrMessageHandler`]: crate::JrMessageHandler
279+ ///
259280/// # Example
260281///
261282/// ```
0 commit comments