rsiot/message/
msg_data.rs1use serde::{Deserialize, Serialize};
2
3use super::{MsgDataBound, MsgKey, system_messages::*};
4
5#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
7pub enum MsgData<TCustom> {
8 System(System),
10 Custom(TCustom),
12}
13
14impl<TMsg> MsgData<TMsg>
15where
16 TMsg: MsgDataBound,
17{
18 pub fn key(&self) -> String {
20 match &self {
21 MsgData::System(system) => format!("System-{}", system.key()),
22 MsgData::Custom(custom) => format!("Custom-{}", custom.key()),
23 }
24 }
25}
26
27impl<TCustom> MsgData<TCustom> where TCustom: MsgDataBound {}