diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b5e3b79..f074c0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,6 @@ jobs: - name: Fmt run: cargo fmt --all -- --check - name: Lint - uses: actions-rs/clippy-check@v1 + run: cargo clippy -- -D warnings with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/src/meter_type.rs b/src/meter_type.rs index 0f2561b..bbd8289 100644 --- a/src/meter_type.rs +++ b/src/meter_type.rs @@ -3,9 +3,10 @@ use serde::Deserialize; /// Meters supported by SolarEdge. -#[derive(Clone, Deserialize, Debug, PartialEq)] +#[derive(Clone, Deserialize, Debug, PartialEq, Default)] pub enum MeterType { /// Solar energy produced. + #[default] Production, /// Total energy consumed (solar + grid) @@ -33,12 +34,6 @@ impl std::fmt::Display for MeterType { } } -impl Default for MeterType { - fn default() -> MeterType { - MeterType::Production - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/site_inverter_technical_data.rs b/src/site_inverter_technical_data.rs index 0aed386..6c69b8e 100644 --- a/src/site_inverter_technical_data.rs +++ b/src/site_inverter_technical_data.rs @@ -99,10 +99,11 @@ pub struct LxData { } /// Inverter operating mode -#[derive(Clone, Deserialize, Debug, PartialEq)] +#[derive(Clone, Deserialize, Debug, PartialEq, Default)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum InverterMode { /// Off + #[default] Off, /// Night mode @@ -179,12 +180,6 @@ impl std::fmt::Display for InverterMode { } } -impl Default for InverterMode { - fn default() -> InverterMode { - InverterMode::Off - } -} - impl Req { /// Create an power details request message that can be sent to SolarEdge. /// diff --git a/src/time_unit.rs b/src/time_unit.rs index b9d5a63..a4d8271 100644 --- a/src/time_unit.rs +++ b/src/time_unit.rs @@ -4,7 +4,7 @@ use serde::Deserialize; /// Time units specified in SolarEdge server monitoring API requests and responses. /// Specifies the aggregation granularity of the data. -#[derive(Clone, Deserialize, Debug, PartialEq)] +#[derive(Clone, Deserialize, Debug, PartialEq, Default)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum TimeUnit { /// 15 minutes @@ -14,6 +14,7 @@ pub enum TimeUnit { Hour, /// 24 hours + #[default] Day, /// 7 days @@ -39,12 +40,6 @@ impl std::fmt::Display for TimeUnit { } } -impl Default for TimeUnit { - fn default() -> TimeUnit { - TimeUnit::Day - } -} - #[cfg(test)] mod tests { use super::*;