pub struct Message<'a> { /* private fields */ }Expand description
A message from the server, read in place from its frame: nothing is copied until the application asks for it.
payload decodes the payload into the application’s own
type, borrowing from the frame where the type does.
Implementations§
Source§impl<'a> Message<'a>
impl<'a> Message<'a>
Sourcepub fn category(&self) -> Option<&str>
pub fn category(&self) -> Option<&str>
The category (c): "U" for updates, "S" for snapshots, "WSE"
for the server’s own messages.
Sourcepub fn position(&self) -> Option<Position>
pub fn position(&self) -> Option<Position>
The message’s position in its topic, when the server keeps the topic’s history.
Sourcepub fn correlation_id(&self) -> Option<&str>
pub fn correlation_id(&self) -> Option<&str>
The correlation id (cid) pairing a reply with its request.
Sourcepub fn priority(&self) -> Option<u8>
pub fn priority(&self) -> Option<u8>
The priority (pri): 1 background, 3 low, 5 normal, 8 high, 10
critical.
Sourcepub fn payload<T: Deserialize<'a>>(&self) -> Result<T, Error>
pub fn payload<T: Deserialize<'a>>(&self) -> Result<T, Error>
The payload (p) decoded into T, from JSON or msgpack as the
connection receives it. A message without a payload decodes as an
empty map.
Sourcepub fn payload_json(&self) -> Option<&'a str>
pub fn payload_json(&self) -> Option<&'a str>
The payload’s JSON text, on a JSON connection.
Sourcepub fn payload_value(&self) -> Result<Value, Error>
pub fn payload_value(&self) -> Result<Value, Error>
The payload as a JSON value, whatever the wire format.
Sourcepub fn to_owned(&self) -> OwnedMessage
pub fn to_owned(&self) -> OwnedMessage
A copy the application can keep. The frame itself is shared, not copied, where it can be.