下面显示的是英文原文。
Messages
Each message reports the MQTT 5 properties it rides: a delivery the response topic and correlation data, a published message the correlation data.
The crate carries two headers in the protocol's own properties: correlation-id in Correlation Data and reply-to in Response Topic.
The message binding describes them, each as a string.
A message a subscription reads reports both.
A requester sets the response topic on its own request, and a message a service publishes is not that request.
So a message an Out slot or a reply sends reports the correlation data alone.
Where a reply goes is the operation's reply object, and a reply named per request reports its address there.
The payload format indicator stays out of the binding.
It follows the media type one message carries in its content-type header, which no declaration knows.
The document reports the media type of the position's codec in the contentType the core fills.
Example
Telemetry reports correlationData and responseTopic; Alert, which the slot publishes, reports correlationData only.
- Macros
- Manual
/// What every device publishes; a subscription reads it.
#[derive(Debug, Deserialize, Serialize, Outgoing)]
struct Telemetry {
device: String,
temperature: f64,
}
/// What the service publishes through its slot when a device runs hot.
#[derive(Debug, Serialize, Outgoing)]
#[outgoing(name = "alerts/overheat")]
struct Alert {
device: String,
}
/// What every device publishes; a subscription reads it.
#[derive(Debug, Deserialize, Serialize, Outgoing, JsonSchema)]
#[schemars(crate = "ruststream::schemars")]
struct Telemetry {
device: String,
temperature: f64,
}
/// What the service publishes through its slot when a device runs hot.
#[derive(Debug, Serialize, Outgoing, JsonSchema)]
#[schemars(crate = "ruststream::schemars")]
#[outgoing(name = "alerts/overheat")]
struct Alert {
device: String,
}