chore: clippy
This commit is contained in:
parent
e3c1044dd3
commit
1c3a002a94
|
@ -18,7 +18,7 @@ async fn main() {
|
|||
let vehicles = api.vehicles().await.unwrap();
|
||||
dbg!(&vehicles);
|
||||
|
||||
if vehicles.len() > 0 {
|
||||
if !vehicles.is_empty() {
|
||||
let vehicle_data = api.vehicle_data(&vehicles[0].id).await.unwrap();
|
||||
dbg!(vehicle_data);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ impl Api {
|
|||
}
|
||||
|
||||
pub async fn from_refresh_token(refresh_token: &RefreshToken) -> Result<Api, TeslatteError> {
|
||||
let response = Self::refresh_token(&refresh_token).await?;
|
||||
let response = Self::refresh_token(refresh_token).await?;
|
||||
Ok(Api::new(
|
||||
response.access_token,
|
||||
Some(response.refresh_token),
|
||||
|
@ -82,7 +82,7 @@ impl Api {
|
|||
match &self.refresh_token {
|
||||
None => Err(TeslatteError::NoRefreshToken),
|
||||
Some(refresh_token) => {
|
||||
let response = Self::refresh_token(&refresh_token).await?;
|
||||
let response = Self::refresh_token(refresh_token).await?;
|
||||
self.access_token = response.access_token;
|
||||
self.refresh_token = Some(response.refresh_token);
|
||||
Ok(())
|
||||
|
|
|
@ -26,13 +26,13 @@ impl EnergySiteArgs {
|
|||
let start_date = args
|
||||
.start
|
||||
.as_ref()
|
||||
.map(|s| DateTime::parse_from_rfc3339(&s).into_diagnostic())
|
||||
.map(|s| DateTime::parse_from_rfc3339(s).into_diagnostic())
|
||||
.transpose()
|
||||
.wrap_err("start_date")?;
|
||||
let end_date = args
|
||||
.end
|
||||
.as_ref()
|
||||
.map(|s| DateTime::parse_from_rfc3339(&s).into_diagnostic())
|
||||
.map(|s| DateTime::parse_from_rfc3339(s).into_diagnostic())
|
||||
.transpose()
|
||||
.wrap_err("end_date")?;
|
||||
let values = CalendarHistoryValues {
|
||||
|
|
|
@ -119,19 +119,19 @@ mod tests {
|
|||
|
||||
if let EnergySite::Powerwall(data) = serde_json::from_str(json).unwrap() {
|
||||
assert_eq!(data.battery_type, "ac_powerwall");
|
||||
assert_eq!(data.backup_capable, true);
|
||||
assert!(data.backup_capable);
|
||||
assert_eq!(data.battery_power, -280);
|
||||
assert_eq!(data.sync_grid_alert_enabled, true);
|
||||
assert_eq!(data.breaker_alert_enabled, false);
|
||||
assert_eq!(data.components.battery, true);
|
||||
assert!(data.sync_grid_alert_enabled);
|
||||
assert!(!data.breaker_alert_enabled);
|
||||
assert!(data.components.battery);
|
||||
assert_eq!(
|
||||
data.components.battery_type,
|
||||
Some("ac_powerwall".to_string())
|
||||
);
|
||||
assert_eq!(data.components.solar, true);
|
||||
assert!(data.components.solar);
|
||||
assert_eq!(data.components.solar_type, Some("pv_panel".to_string()));
|
||||
assert_eq!(data.components.grid, true);
|
||||
assert_eq!(data.components.load_meter, true);
|
||||
assert!(data.components.grid);
|
||||
assert!(data.components.load_meter);
|
||||
assert_eq!(data.components.market_type, "residential");
|
||||
} else {
|
||||
panic!("Expected PowerwallData");
|
||||
|
@ -220,8 +220,8 @@ mod tests {
|
|||
assert_eq!(v.access_type, "OWNER");
|
||||
assert_eq!(v.tokens, vec!["asdf1234"]);
|
||||
assert_eq!(v.state, "online");
|
||||
assert_eq!(v.in_service, false);
|
||||
assert_eq!(v.calendar_enabled, true);
|
||||
assert!(!v.in_service);
|
||||
assert!(v.calendar_enabled);
|
||||
assert_eq!(v.api_version, 42);
|
||||
assert_eq!(v.backseat_token, None);
|
||||
assert_eq!(v.backseat_token_updated_at, None);
|
||||
|
|
|
@ -285,7 +285,7 @@ where
|
|||
pub(crate) fn join_query_pairs(pairs: &[(&str, String)]) -> String {
|
||||
pairs
|
||||
.iter()
|
||||
.map(|(k, v)| format!("{}={}", k, v.replace("+", "%2B")))
|
||||
.map(|(k, v)| format!("{}={}", k, v.replace('+', "%2B")))
|
||||
.collect::<Vec<_>>()
|
||||
.join("&")
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ pub struct PowerwallEnergyHistoryValues {
|
|||
|
||||
impl Values for PowerwallEnergyHistoryValues {
|
||||
fn format(&self, url: &str) -> String {
|
||||
let url = url.replace("{}", &format!("{}", self.powerwall_id.0));
|
||||
let url = url.replace("{}", &self.powerwall_id.0.to_string());
|
||||
let mut pairs: Vec<(&str, String)> = vec![
|
||||
("period", self.period.to_string()),
|
||||
("kind", self.kind.to_string()),
|
||||
|
|
Loading…
Reference in a new issue