pub enum ServerMessage {
Notification(Notification),
Request {
id: RequestId,
request: ServerRequest,
},
}Expand description
A message coming from the app-server.
Replaces the previous loose { method, params } shape with typed enums.
Match on the outer variant first to distinguish notifications (no response)
from requests (need crate::AsyncClient::respond /
crate::SyncClient::respond).
Variants§
Notification(Notification)
A notification — no response required.
Request
A request — call respond(id, ...) on the client with the matching id.
Implementations§
Source§impl ServerMessage
impl ServerMessage
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
true if this message is an unmodeled method (notification or request).
Sourcepub fn from_json_str(s: &str) -> Result<Self, Error>
pub fn from_json_str(s: &str) -> Result<Self, Error>
Parse a raw app-server frame (one JSON-RPC line) into a ServerMessage.
This is the same parse path the AsyncClient and
SyncClient run on incoming lines, exposed for
replay, recovery, and test fixtures that need to decode a captured frame
without a live client.
A frame is a ServerMessage only if it is a server-initiated
notification or request. A JSON-RPC response / error (a reply to a
client request) is not a server message and returns
Error::Protocol. Unknown methods decode to
the Unknown variants rather than erroring; a modeled method whose
params don’t fit returns Error::Deserialization
carrying the raw frame.
Sourcepub fn from_value(value: Value) -> Result<Self, Error>
pub fn from_value(value: Value) -> Result<Self, Error>
Parse a serde_json::Value frame into a ServerMessage.
See from_json_str for the parsing contract.
Trait Implementations§
Source§impl Clone for ServerMessage
impl Clone for ServerMessage
Source§fn clone(&self) -> ServerMessage
fn clone(&self) -> ServerMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more