Compare commits
	
		
			3 Commits
		
	
	
		
			0a5891b5be
			...
			21cb416f41
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 21cb416f41 | |||
| 3ccee9f897 | |||
| 2266d7ecef | 
| @ -1,6 +1,6 @@ | ||||
| [package] | ||||
| name = "easee" | ||||
| version = "0.1.0" | ||||
| version = "0.1.1" | ||||
| edition = "2021" | ||||
| authors = ["Maxime Augier <max@xolus.net>"] | ||||
| description = "Rust bindings for the Easee cloud API for EV charging devices" | ||||
| @ -22,3 +22,6 @@ 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"] | ||||
|  | ||||
| @ -1,4 +1,7 @@ | ||||
| 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; | ||||
| @ -83,16 +86,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() | ||||
| @ -226,7 +229,8 @@ 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 { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user