Compare commits

..

No commits in common. "21cb416f41c2f38cf016e2395b14ac13fb433e14" and "0a5891b5be6db0a366d8f38bbf3c3b939e104b97" have entirely different histories.

2 changed files with 12 additions and 19 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "easee"
version = "0.1.1"
version = "0.1.0"
edition = "2021"
authors = ["Maxime Augier <max@xolus.net>"]
description = "Rust bindings for the Easee cloud API for EV charging devices"
@ -22,6 +22,3 @@ thiserror = "1.0.63"
tracing = "0.1.40"
tungstenite = { version = "0.23.0", optional = true, features = ["rustls-tls-native-roots"] }
ureq = { version = "2.10.0", features = ["json"] }
[features]
default = ["tungstenite"]

View File

@ -1,7 +1,4 @@
use serde::{
de::{DeserializeOwned, IntoDeserializer},
Deserialize,
};
use serde::{de::{DeserializeOwned, IntoDeserializer}, Deserialize};
use serde_repr::Deserialize_repr;
use std::num::{ParseFloatError, ParseIntError};
use thiserror::Error;
@ -86,16 +83,16 @@ pub enum ParseError {
impl ObservationData {
fn from_dynamic(value: String, data_type: DataType) -> Result<ObservationData, ParseError> {
Ok(match data_type {
DataType::Boolean => ObservationData::Boolean(match &*value {
"False" | "false" => false,
"True" | "true" => true,
other => {
other
.parse::<i64>()
.map_err(move |e| ParseError::Integer(value, e))?
!= 0
DataType::Boolean => ObservationData::Boolean(
match &*value {
"False"|"false" => { false },
"True"|"true" => { true }
other => other
.parse::<i64>()
.map_err(move |e| ParseError::Integer(value, e))?
!= 0,
}
}),
),
DataType::Double => ObservationData::Double(
value
.parse()
@ -229,8 +226,7 @@ fn op_mode_from_int(mode: i64) -> ChargerOpMode {
}
fn deserialize_i64<T: DeserializeOwned>(value: i64) -> Option<T> {
T::deserialize(<i64 as IntoDeserializer<serde::de::value::Error>>::into_deserializer(value))
.ok()
T::deserialize(<i64 as IntoDeserializer<serde::de::value::Error>>::into_deserializer(value)).ok()
}
impl Observation {