Skip to content

Commit d1a7a8d

Browse files
committed
format tweaks etc
1 parent 911816b commit d1a7a8d

File tree

3 files changed

+39
-24
lines changed

3 files changed

+39
-24
lines changed

nexus/db-queries/src/db/datastore/fm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,10 @@ mod tests {
10411041
assert_eq!(sitrep.metadata.comment, current_sitrep.metadata.comment);
10421042

10431043
// Trying to insert the same sitrep again should fail.
1044-
let err =
1045-
datastore.fm_sitrep_insert(&opctx, sitrep.clone()).await.unwrap_err();
1044+
let err = datastore
1045+
.fm_sitrep_insert(&opctx, sitrep.clone())
1046+
.await
1047+
.unwrap_err();
10461048
assert!(err.to_string().contains("duplicate key"));
10471049

10481050
// Clean up.

nexus/types/src/fm/case.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ impl Case {
3636
self.time_closed.is_none()
3737
}
3838

39-
pub fn display_indented(&self, indent: usize, sitrep_id: Option<SitrepUuid>) -> impl fmt::Display + '_ {
39+
pub fn display_indented(
40+
&self,
41+
indent: usize,
42+
sitrep_id: Option<SitrepUuid>,
43+
) -> impl fmt::Display + '_ {
4044
DisplayCase { case: self, indent, sitrep_id }
4145
}
4246
}
@@ -119,24 +123,34 @@ impl fmt::Display for DisplayCase<'_> {
119123
} = self;
120124

121125
let this_sitrep = move |s| {
122-
if Some(s) == sitrep_id {
123-
" <-- this sitrep"
124-
} else {
125-
""
126-
}
126+
if Some(s) == sitrep_id { " <-- this sitrep" } else { "" }
127127
};
128128

129129
writeln!(
130130
f,
131131
"{:>indent$}case {id}",
132132
if indent > 0 { BULLET } else { "" }
133133
)?;
134-
writeln!(f, "{:>indent$}-----------------------------------------", "")?;
134+
writeln!(
135+
f,
136+
"{:>indent$}-----------------------------------------",
137+
""
138+
)?;
135139
writeln!(f, "{:>indent$}diagnosis engine: {de}", "")?;
136-
writeln!(f, "{:>indent$}created in sitrep: {created_sitrep_id}{}", "", this_sitrep(*created_sitrep_id))?;
140+
writeln!(
141+
f,
142+
"{:>indent$}created in sitrep: {created_sitrep_id}{}",
143+
"",
144+
this_sitrep(*created_sitrep_id)
145+
)?;
137146
writeln!(f, "{:>indent$} at: {time_created}", "")?;
138147
if let Some(closed_id) = closed_sitrep_id {
139-
writeln!(f, "{:>indent$}closed in sitrep: {closed_id}{}", "", this_sitrep(*closed_id))?;
148+
writeln!(
149+
f,
150+
"{:>indent$}closed in sitrep: {closed_id}{}",
151+
"",
152+
this_sitrep(*closed_id)
153+
)?;
140154
if let Some(time_closed) = time_closed {
141155
writeln!(f, "{:>indent$} at: {time_closed}", "")?;
142156
} else {
@@ -172,7 +186,7 @@ impl fmt::Display for DisplayCase<'_> {
172186
f,
173187
"{:>indent$}added in sitrep: {assigned_sitrep_id}{}",
174188
"",
175-
this_sitrep(*assigned_sitrep_id)
189+
this_sitrep(*assigned_sitrep_id)
176190
)?;
177191
writeln!(f, "{:>indent$}comment: {comment}\n", "")?;
178192
}
@@ -184,12 +198,12 @@ impl fmt::Display for DisplayCase<'_> {
184198
for ImpactedSpSlot { sp_type, slot, created_sitrep_id, comment } in
185199
impacted_sp_slots
186200
{
187-
writeln!(f, "{BULLET:>indent$}{sp_type:<6} {slot:02}")?;
201+
writeln!(f, "{BULLET:>indent$}{sp_type:<6} {slot}")?;
188202
writeln!(
189203
f,
190204
"{:>indent$}added in sitrep: {created_sitrep_id}{}",
191205
"",
192-
this_sitrep(*created_sitrep_id)
206+
this_sitrep(*created_sitrep_id)
193207
)?;
194208
writeln!(f, "{:>indent$}comment: {comment}\n", "")?;
195209
}
@@ -207,7 +221,7 @@ impl fmt::Display for DisplayCase<'_> {
207221
f,
208222
"{:>indent$}requested in sitrep: {requested_sitrep_id}{}\n",
209223
"",
210-
this_sitrep(*requested_sitrep_id)
224+
this_sitrep(*requested_sitrep_id)
211225
)?;
212226
}
213227
}

nexus/types/src/fm/ereport.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,17 @@ pub enum Reporter {
6969

7070
impl fmt::Display for Reporter {
7171
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
72+
// Display format based on:
73+
// https://rfd.shared.oxide.computer/rfd/200#_labeling
7274
match self {
73-
Self::Sp { sp_type: SpType::Sled, slot } => {
74-
write!(f, "Sled (SP) {slot:02}")
75-
}
76-
Self::Sp { sp_type: SpType::Switch, slot } => {
77-
write!(f, "Switch {slot}")
78-
}
79-
Self::Sp { sp_type: SpType::Power, slot } => {
80-
write!(f, "PSC {slot}")
75+
Self::Sp { sp_type: sp_type @ SpType::Sled, slot } => {
76+
write!(f, "{sp_type} {slot:<2} (SP)")
8177
}
8278
Self::HostOs { sled } => {
83-
write!(f, "Sled (OS) {sled:?}")
79+
write!(f, "{} {sled:?} (OS)", SpType::Sled)
80+
}
81+
Self::Sp { sp_type, slot } => {
82+
write!(f, "{sp_type} {slot}")
8483
}
8584
}
8685
}

0 commit comments

Comments
 (0)