1use crate::Graph;
2use core::fmt::Write;
3
4impl<C> Graph<C> {
5 pub fn debug_dump(&self) -> String {
7 let mut out = String::new();
8 writeln!(&mut out, "Graph(revision={})", self.revision().get())
9 .expect("writing to String cannot fail");
10
11 writeln!(&mut out, "Scopes:").expect("writing to String cannot fail");
12 for scope in self.scopes() {
13 writeln!(
14 &mut out,
15 " {:?} name={:?} parent={:?} closed={}",
16 scope.id(),
17 scope.debug_name(),
18 scope.parent(),
19 scope.is_closed()
20 )
21 .expect("writing to String cannot fail");
22 }
23
24 writeln!(&mut out, "Nodes:").expect("writing to String cannot fail");
25 for node in self.nodes() {
26 writeln!(
27 &mut out,
28 " {:?} kind={:?} name={:?} scope={:?} deps={:?}",
29 node.id(),
30 node.kind(),
31 node.debug_name(),
32 node.owning_scope(),
33 node.dependencies().as_slice()
34 )
35 .expect("writing to String cannot fail");
36 }
37
38 writeln!(&mut out, "Dependency paths:").expect("writing to String cannot fail");
39 for node in self.nodes() {
40 for dependency in node.dependencies().as_slice() {
41 writeln!(&mut out, " {dependency:?} -> {:?}", node.id())
42 .expect("writing to String cannot fail");
43 }
44 }
45
46 writeln!(&mut out, "Resources:").expect("writing to String cannot fail");
47 for (key, owners) in &self.resource_owners {
48 writeln!(&mut out, " {key:?} owners={owners:?}")
49 .expect("writing to String cannot fail");
50 }
51
52 writeln!(&mut out, "Outputs:").expect("writing to String cannot fail");
53 for output in self.outputs.values() {
54 writeln!(
55 &mut out,
56 " {:?} name={:?} scope={:?} deps={:?}",
57 output.key(),
58 output.debug_name(),
59 output.scope(),
60 output.dependencies().as_slice()
61 )
62 .expect("writing to String cannot fail");
63 }
64
65 writeln!(&mut out, "Audit:").expect("writing to String cannot fail");
66 for explanation in self.audit.node_changes.values() {
67 writeln!(
68 &mut out,
69 " node={:?} tx={:?} revision={:?} event={:?}",
70 explanation.node,
71 explanation.transaction_id,
72 explanation.revision,
73 explanation.event
74 )
75 .expect("writing to String cannot fail");
76 }
77 for explanation in self.audit.resource_commands.values() {
78 writeln!(
79 &mut out,
80 " resource={:?} tx={:?} revision={:?} kind={:?} cause={:?}",
81 explanation.key,
82 explanation.transaction_id,
83 explanation.revision,
84 explanation.kind,
85 explanation.cause
86 )
87 .expect("writing to String cannot fail");
88 }
89 for explanation in self.audit.output_frames.values() {
90 writeln!(
91 &mut out,
92 " output={:?} tx={:?} revision={:?} kind={:?}",
93 explanation.output_key,
94 explanation.transaction_id,
95 explanation.revision,
96 explanation.kind
97 )
98 .expect("writing to String cannot fail");
99 }
100
101 out
102 }
103}