1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::ProtocolId;
use bytes::Bytes;
use serde::Serialize;
use std::fmt::Debug;
#[derive(Clone, Eq, PartialEq, Serialize)]
pub struct Message {
pub protocol_id: ProtocolId,
#[serde(skip)]
pub mdata: Bytes,
}
impl Debug for Message {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mdata_str = if self.mdata.len() <= 10 {
format!("{:?}", self.mdata)
} else {
format!("{:?}...", self.mdata.slice(..10))
};
write!(
f,
"Message {{ protocol: {:?}, mdata: {} }}",
self.protocol_id, mdata_str
)
}
}