kernel/event/record/
log.rs1use serde::{Deserialize, Serialize};
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
16#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
17pub struct LogTruncated {
18 pub dropped_bytes: u64,
19}
20
21#[cfg(test)]
22#[allow(clippy::unwrap_used, clippy::expect_used, reason = "test code")]
23mod tests {
24 use super::*;
25 use crate::event::Payload;
26
27 #[test]
29 fn a_truncation_line_writes_the_one_key_the_hand_written_map_wrote() {
30 let mut hand = serde_json::Map::new();
31 hand.insert("dropped_bytes".to_owned(), serde_json::Value::from(191u64));
32 let hand = Payload::new(hand).unwrap();
33 let typed = Payload::of(&LogTruncated { dropped_bytes: 191 }).unwrap();
34 assert_eq!(
35 serde_json::to_string(&typed).unwrap(),
36 serde_json::to_string(&hand).unwrap()
37 );
38 assert_eq!(typed.read::<LogTruncated>().unwrap().dropped_bytes, 191);
39 }
40}