]> git.proxmox.com Git - proxmox-resource-scheduling.git/commitdiff
reorder impl blocks
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 11 Nov 2022 10:30:48 +0000 (11:30 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 11 Nov 2022 12:50:42 +0000 (13:50 +0100)
so they're next to their types

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/pve_static.rs
src/topsis.rs

index d131fe343ac37341af7813714d65f1c8a74b6b9c..f8757f300754be632882b802b4abbc4826ff3097 100644 (file)
@@ -19,14 +19,12 @@ pub struct StaticNodeUsage {
     pub maxmem: usize,
 }
 
-#[derive(Serialize, Deserialize)]
-#[serde(rename_all = "kebab-case")]
-/// Static usage information of an HA resource.
-pub struct StaticServiceUsage {
-    /// Number of assigned CPUs or CPU limit.
-    pub maxcpu: f64,
-    /// Maximum assigned memory in bytes.
-    pub maxmem: usize,
+impl StaticNodeUsage {
+    /// Add usage of `service` to the node's usage.
+    pub fn add_service_usage(&mut self, service: &StaticServiceUsage) {
+        self.cpu = add_cpu_usage(self.cpu, self.maxcpu as f64, service.maxcpu);
+        self.mem += service.maxmem;
+    }
 }
 
 /// Calculate new CPU usage in percent.
@@ -39,12 +37,14 @@ fn add_cpu_usage(old: f64, max: f64, add: f64) -> f64 {
     }
 }
 
-impl StaticNodeUsage {
-    /// Add usage of `service` to the node's usage.
-    pub fn add_service_usage(&mut self, service: &StaticServiceUsage) {
-        self.cpu = add_cpu_usage(self.cpu, self.maxcpu as f64, service.maxcpu);
-        self.mem += service.maxmem;
-    }
+#[derive(Serialize, Deserialize)]
+#[serde(rename_all = "kebab-case")]
+/// Static usage information of an HA resource.
+pub struct StaticServiceUsage {
+    /// Number of assigned CPUs or CPU limit.
+    pub maxcpu: f64,
+    /// Maximum assigned memory in bytes.
+    pub maxmem: usize,
 }
 
 criteria_struct! {
index 3a37353a152ff465641f0a85fa0faa9bb4737b1c..d86a2b9e3ac8ad6a26ffbd32563cd02f8bc40e4d 100644 (file)
@@ -49,16 +49,6 @@ impl TopsisCriterion {
 /// A normalized array of `TopsisCriterion`.
 pub struct TopsisCriteria<const N_CRITERIA: usize>([TopsisCriterion; N_CRITERIA]);
 
-/// A normalized matrix used for scoring with the TOPSIS algorithm.
-pub struct TopsisMatrix<const N_CRITERIA: usize>(Vec<[f64; N_CRITERIA]>);
-
-/// Idealized alternatives from a `TopsisMatrix`. That is, the alternative consisting of the best
-/// (respectively worst) value among the alternatives in the matrix for each single criterion.
-struct TopsisIdealAlternatives<const N_CRITERIA: usize> {
-    best: [f64; N_CRITERIA],
-    worst: [f64; N_CRITERIA],
-}
-
 impl<const N: usize> TopsisCriteria<N> {
     /// Create a new instance of normalized TOPSIS criteria.
     ///
@@ -95,6 +85,9 @@ impl<const N: usize> TopsisCriteria<N> {
     }
 }
 
+/// A normalized matrix used for scoring with the TOPSIS algorithm.
+pub struct TopsisMatrix<const N_CRITERIA: usize>(Vec<[f64; N_CRITERIA]>);
+
 impl<const N: usize> TopsisMatrix<N> {
     /// Values of the matrix for the fixed critierion with index `index`.
     fn fixed_criterion(&self, index: usize) -> Vec<f64> {
@@ -136,6 +129,13 @@ impl<const N: usize> TopsisMatrix<N> {
     }
 }
 
+/// Idealized alternatives from a `TopsisMatrix`. That is, the alternative consisting of the best
+/// (respectively worst) value among the alternatives in the matrix for each single criterion.
+struct TopsisIdealAlternatives<const N_CRITERIA: usize> {
+    best: [f64; N_CRITERIA],
+    worst: [f64; N_CRITERIA],
+}
+
 /// Compute the idealized alternatives from the given `matrix`. The `criteria` are required to know
 /// if a critierion should be maximized or minimized.
 fn ideal_alternatives<const N: usize>(