1use std::fmt;
18
19pub use matrix_sdk_common::debug::*;
20use matrix_sdk_common::deserialized_responses::ProcessedToDeviceEvent;
21use ruma::{
22 api::client::sync::sync_events::v3::{InvitedRoom, KnockedRoom},
23 serde::Raw,
24};
25
26pub struct DebugListOfRawEventsNoId<'a, T>(pub &'a [Raw<T>]);
29
30#[cfg(not(tarpaulin_include))]
31impl<T> fmt::Debug for DebugListOfRawEventsNoId<'_, T> {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 let mut list = f.debug_list();
34 list.entries(self.0.iter().map(DebugRawEventNoId));
35 list.finish()
36 }
37}
38
39pub struct DebugListOfProcessedToDeviceEvents<'a>(pub &'a [ProcessedToDeviceEvent]);
42
43#[cfg(not(tarpaulin_include))]
44impl fmt::Debug for DebugListOfProcessedToDeviceEvents<'_> {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 let mut list = f.debug_list();
47 list.entries(self.0.iter().map(|e| DebugRawEventNoId(e.as_raw())));
48 list.finish()
49 }
50}
51
52pub struct DebugInvitedRoom<'a>(pub &'a InvitedRoom);
56
57#[cfg(not(tarpaulin_include))]
58impl fmt::Debug for DebugInvitedRoom<'_> {
59 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60 f.debug_struct("InvitedRoom")
61 .field("invite_state", &DebugListOfRawEvents(&self.0.invite_state.events))
62 .finish()
63 }
64}
65
66pub struct DebugKnockedRoom<'a>(pub &'a KnockedRoom);
70
71#[cfg(not(tarpaulin_include))]
72impl fmt::Debug for DebugKnockedRoom<'_> {
73 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74 f.debug_struct("KnockedRoom")
75 .field("knock_state", &DebugListOfRawEvents(&self.0.knock_state.events))
76 .finish()
77 }
78}
79
80pub(crate) struct DebugListOfRawEvents<'a, T>(pub &'a [Raw<T>]);
81
82#[cfg(not(tarpaulin_include))]
83impl<T> fmt::Debug for DebugListOfRawEvents<'_, T> {
84 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
85 let mut list = f.debug_list();
86 list.entries(self.0.iter().map(DebugRawEvent));
87 list.finish()
88 }
89}