2
2
3
3
use anyhow:: { anyhow, Result } ;
4
4
use std:: collections:: HashMap ;
5
+ use std:: fmt;
5
6
use std:: mem:: take;
6
7
use svd_rs:: {
7
8
array:: names, cluster, field, peripheral, register, BitRange , Cluster , ClusterInfo , DeriveFrom ,
@@ -50,6 +51,17 @@ impl BlockPath {
50
51
}
51
52
}
52
53
54
+ impl fmt:: Display for BlockPath {
55
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
56
+ f. write_str ( & self . peripheral ) ?;
57
+ for p in & self . path {
58
+ f. write_str ( "." ) ?;
59
+ f. write_str ( p) ?;
60
+ }
61
+ Ok ( ( ) )
62
+ }
63
+ }
64
+
53
65
/// Path to `register` element
54
66
#[ derive( Clone , Debug , PartialEq , Hash , Eq ) ]
55
67
pub struct RegisterPath {
@@ -78,6 +90,15 @@ impl RegisterPath {
78
90
}
79
91
}
80
92
93
+ impl fmt:: Display for RegisterPath {
94
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
95
+ self . block . fmt ( f) ?;
96
+ f. write_str ( "." ) ?;
97
+ f. write_str ( & self . name ) ?;
98
+ Ok ( ( ) )
99
+ }
100
+ }
101
+
81
102
/// Path to `field` element
82
103
#[ derive( Clone , Debug , PartialEq , Hash , Eq ) ]
83
104
pub struct FieldPath {
@@ -116,6 +137,15 @@ impl FieldPath {
116
137
}
117
138
}
118
139
140
+ impl fmt:: Display for FieldPath {
141
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
142
+ self . register . fmt ( f) ?;
143
+ f. write_str ( "." ) ?;
144
+ f. write_str ( & self . name ) ?;
145
+ Ok ( ( ) )
146
+ }
147
+ }
148
+
119
149
/// Path to `enumeratedValues` element
120
150
#[ derive( Clone , Debug , PartialEq , Hash , Eq ) ]
121
151
pub struct EnumPath {
@@ -141,6 +171,15 @@ impl EnumPath {
141
171
}
142
172
}
143
173
174
+ impl fmt:: Display for EnumPath {
175
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
176
+ self . field . fmt ( f) ?;
177
+ f. write_str ( "." ) ?;
178
+ f. write_str ( & self . name ) ?;
179
+ Ok ( ( ) )
180
+ }
181
+ }
182
+
144
183
#[ derive( Clone , Debug , Default ) ]
145
184
pub struct Index < ' a > {
146
185
pub peripherals : HashMap < BlockPath , & ' a Peripheral > ,
0 commit comments