Update
This commit is contained in:
parent
76b43a0386
commit
220a446fb6
21 changed files with 677 additions and 111 deletions
|
@ -7,6 +7,6 @@ edition = "2021"
|
|||
chrono = { version = "0.4.38", features = ["serde"] }
|
||||
chrono-tz = { version = "0.10.0", features = ["serde"] }
|
||||
cron = { version = "0.13.0", features = ["serde"] }
|
||||
nutype = { version = "0.5.0", features = ["serde"] }
|
||||
serde = { version = "1.0.214", features = ["derive"] }
|
||||
serde_with = { version = "3.11.0", features = ["chrono_0_4"] }
|
||||
validated_newtype = "0.1.1"
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
use chrono::Duration;
|
||||
use chrono_tz::Tz;
|
||||
use cron::Schedule;
|
||||
use nutype::nutype;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use validated_newtype::validated_newtype;
|
||||
|
||||
validated_newtype! {
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Serialize, Clone, Copy)]
|
||||
u8 => pub Percent
|
||||
if |n: &u8| *n <= 100;
|
||||
error "percent must in range 0-100"
|
||||
#[nutype(
|
||||
derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq),
|
||||
validate(predicate = is_valid_percent)
|
||||
)]
|
||||
pub struct Percent(u8);
|
||||
|
||||
fn is_valid_percent(n: &u8) -> bool {
|
||||
*n <= 100
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
|
||||
|
@ -66,3 +69,11 @@ pub enum Corner {
|
|||
BottomLeft,
|
||||
BottomRight,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
|
||||
pub struct DeviceStatePost {
|
||||
pub battery_charging: bool,
|
||||
pub battery_level: Percent,
|
||||
pub battery_current: i16,
|
||||
pub battery_voltage: i16,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue