Commit 1e1d20d7 authored by xuwencheng's avatar xuwencheng

upgrade

parent 01a90016
...@@ -17,26 +17,15 @@ impl PublishMessage { ...@@ -17,26 +17,15 @@ impl PublishMessage {
pub fn new(id: i64, ty: i32, qos: Qos, data: Option<String>) -> Self { pub fn new(id: i64, ty: i32, qos: Qos, data: Option<String>) -> Self {
Self { id, ty, qos, data } Self { id, ty, qos, data }
} }
pub fn to_push(&self, c_types: &[i32], key: Option<impl AsRef<str>>) -> PushMessage {
PushMessage {
client_types: c_types.iter().map(|v| *v).collect::<Vec<i32>>(),
business_type: self.ty,
message_id: self.id,
key: key.map(|s| s.as_ref().to_string()),
qos: self.qos,
payload: self.data.clone(),
}
}
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct PushMessage { pub struct PushMessage {
client_types: Vec<i32>, pub client_types: Vec<i32>,
business_type: i32, pub business_type: i32,
message_id: i64, pub message_id: i64,
key: Option<String>, pub key: Option<String>,
qos: Qos, pub qos: Qos,
payload: Option<String>, pub payload: Option<String>,
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment