Updated rust toolchain
This commit is contained in:
parent
e8d5698835
commit
14aabe202d
|
@ -120,9 +120,6 @@ impl OnOff for HueGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod message {
|
mod message {
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use serde::ser::SerializeStruct;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
@ -164,46 +161,5 @@ mod message {
|
||||||
pub fn any_on(&self) -> bool {
|
pub fn any_on(&self) -> bool {
|
||||||
self.state.any_on
|
self.state.any_on
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn all_on(&self) -> bool {
|
|
||||||
// self.state.all_on
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Timeout {
|
|
||||||
timeout: Option<Duration>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Timeout {
|
|
||||||
pub fn new(timeout: Option<Duration>) -> Self {
|
|
||||||
Self { timeout }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Timeout {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
let len = if self.timeout.is_some() { 2 } else { 1 };
|
|
||||||
let mut state = serializer.serialize_struct("TimerMessage", len)?;
|
|
||||||
if self.timeout.is_some() {
|
|
||||||
state.serialize_field("status", "enabled")?;
|
|
||||||
} else {
|
|
||||||
state.serialize_field("status", "disabled")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(timeout) = self.timeout {
|
|
||||||
let seconds = timeout.as_secs() % 60;
|
|
||||||
let minutes = (timeout.as_secs() / 60) % 60;
|
|
||||||
let hours = timeout.as_secs() / 3600;
|
|
||||||
|
|
||||||
let time = format!("PT{hours:<02}:{minutes:<02}:{seconds:<02}");
|
|
||||||
state.serialize_field("localtime", &time)?;
|
|
||||||
};
|
|
||||||
|
|
||||||
state.end()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2024-07-25"
|
channel = "nightly-2024-12-06"
|
||||||
components = ["rustfmt", "clippy", "rust-analyzer"]
|
components = ["rustfmt", "clippy", "rust-analyzer"]
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user