pub trait FromMessage<T>where
Self: Sized,{
// Required method
fn from_message(
message: T,
request_id: Option<RequestId>,
) -> Result<Self, JsonrpcErrorError>;
}
Expand description
A trait for converting a message of type T
into Self
.
This is useful for transforming mcp messages into a Type that could be serialized into a JsonrpcMessage.
For example, a ServerMessage can be constructed from a rust_mcp_schema::PingRequest by attaching a RequestId. Eventually, the ServerMessage can be serialized into a valid JsonrpcMessage for transmission over the transport.
Required Methods§
fn from_message( message: T, request_id: Option<RequestId>, ) -> Result<Self, JsonrpcErrorError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.