percpu_writer_bindings/
buffer_types.rs1#![no_std]
10
11use zx_types::zx_instant_boot_ticks_t;
12
13mod sys {
14 include!(rustenv_path::envpath!("PERCPU_WRITER_BINDINGS_RS"));
15}
16
17pub use sys::{
18 percpu_writer_DroppedRecordDurationEvent as DroppedRecordDurationEvent,
19 percpu_writer_DroppedRecordStats as DroppedRecordStats,
20};
21
22impl Default for DroppedRecordStats {
23 #[inline]
24 fn default() -> Self {
25 Self::new()
26 }
27}
28
29impl DroppedRecordStats {
30 #[inline]
32 pub const fn new() -> Self {
33 Self {
34 first_dropped: 0,
35 last_dropped: 0,
36 num_dropped: 0,
37 bytes_dropped: 0,
38 has_dropped: false,
39 __bindgen_padding_0: [0; 7],
40 }
41 }
42
43 #[inline]
45 pub fn reset(&mut self) {
46 self.first_dropped = 0;
47 self.last_dropped = 0;
48 self.num_dropped = 0;
49 self.bytes_dropped = 0;
50 self.has_dropped = false;
51 }
52
53 #[inline]
55 pub fn track(&mut self, now: zx_instant_boot_ticks_t, size: u32) {
56 if !self.has_dropped {
57 self.first_dropped = now;
58 self.has_dropped = true;
59 }
60 self.last_dropped = now;
61 self.num_dropped = self.num_dropped.wrapping_add(1);
62 self.bytes_dropped = self.bytes_dropped.wrapping_add(size);
63 }
64
65 #[inline]
67 pub const fn has_dropped(&self) -> bool {
68 self.has_dropped
69 }
70}