Skip to content

Commit ae2e508

Browse files
committed
few more things
1 parent b94f9c6 commit ae2e508

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

nexus/types/src/deployment.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,19 @@ pub struct BlueprintMeasurements {
19411941
pub measurements: BTreeSet<BlueprintSingleMeasurement>,
19421942
}
19431943

1944+
impl Display for BlueprintMeasurements {
1945+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1946+
if self.measurements.is_empty() {
1947+
writeln!(f, "(empty)")?;
1948+
} else {
1949+
for m in &self.measurements {
1950+
writeln!(f, "{m}")?;
1951+
}
1952+
}
1953+
Ok(())
1954+
}
1955+
}
1956+
19441957
impl From<BlueprintMeasurements> for BTreeSet<OmicronSingleMeasurement> {
19451958
fn from(value: BlueprintMeasurements) -> Self {
19461959
if value.measurements.is_empty() {
@@ -1955,6 +1968,18 @@ impl From<BlueprintMeasurements> for BTreeSet<OmicronSingleMeasurement> {
19551968
}
19561969
}
19571970

1971+
impl From<BlueprintMeasurements> for BTreeSet<BlueprintSingleMeasurement> {
1972+
fn from(value: BlueprintMeasurements) -> Self {
1973+
value.measurements
1974+
}
1975+
}
1976+
1977+
impl From<BTreeSet<BlueprintSingleMeasurement>> for BlueprintMeasurements {
1978+
fn from(measurements: BTreeSet<BlueprintSingleMeasurement>) -> Self {
1979+
Self { measurements }
1980+
}
1981+
}
1982+
19581983
impl BlueprintMeasurements {
19591984
pub fn default_contents() -> Self {
19601985
Self { measurements: BTreeSet::new() }
@@ -1963,6 +1988,11 @@ impl BlueprintMeasurements {
19631988
pub fn append_measurement(&mut self, single: BlueprintSingleMeasurement) {
19641989
self.measurements.insert(single);
19651990
}
1991+
1992+
// An empty measurement set here corresponds to the install dataset
1993+
pub fn is_install_dataset(&self) -> bool {
1994+
self.measurements.is_empty()
1995+
}
19661996
}
19671997

19681998
/// Describes the desired contents for both host phase 2 slots.

0 commit comments

Comments
 (0)