From 3613c2cbdf6f6facadd1b6fc5d850b42ac61db62 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Sun, 9 Apr 2023 23:01:21 +0200 Subject: [PATCH] Changed how TODO notes are marked to properly highlight in vim --- google-home/src/fullfillment.rs | 6 +++--- google-home/src/response/execute.rs | 2 +- google-home/src/response/query.rs | 2 +- google-home/src/traits.rs | 2 +- src/auth.rs | 2 +- src/config.rs | 4 ++-- src/devices.rs | 8 ++++---- src/devices/audio_setup.rs | 2 +- src/devices/ikea_outlet.rs | 10 +++++----- src/devices/kasa_outlet.rs | 2 +- src/devices/wake_on_lan.rs | 2 +- src/error.rs | 4 ++-- src/light_sensor.rs | 4 ++-- src/presence.rs | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/google-home/src/fullfillment.rs b/google-home/src/fullfillment.rs index 6f32ef1..5799d7f 100644 --- a/google-home/src/fullfillment.rs +++ b/google-home/src/fullfillment.rs @@ -22,7 +22,7 @@ impl GoogleHome { } pub fn handle_request(&self, request: Request, mut devices: &mut HashMap<&str, &mut dyn GoogleHomeDevice>) -> Result { - // @TODO What do we do if we actually get more then one thing in the input array, right now + // TODO: What do we do if we actually get more then one thing in the input array, right now // we only respond to the first thing let payload = request .inputs @@ -93,12 +93,12 @@ impl GoogleHome { } let results = command.execution.iter().map(|cmd| { - // @TODO We should also return the state after update in the state + // TODO: We should also return the state after update in the state // struct, however that will make things WAY more complicated device.execute(cmd) }).collect::, ErrorCode>>(); - // @TODO We only get one error not all errors + // TODO: We only get one error not all errors if let Err(err) = results { return (id, Err(err)); } else { diff --git a/google-home/src/response/execute.rs b/google-home/src/response/execute.rs index ee55106..d517b29 100644 --- a/google-home/src/response/execute.rs +++ b/google-home/src/response/execute.rs @@ -99,6 +99,6 @@ mod tests { println!("{}", json); - // @TODO Add a known correct output to test against + // TODO: Add a known correct output to test against } } diff --git a/google-home/src/response/query.rs b/google-home/src/response/query.rs index d2bfbf0..51fcfba 100644 --- a/google-home/src/response/query.rs +++ b/google-home/src/response/query.rs @@ -87,6 +87,6 @@ mod tests { println!("{}", json); - // @TODO Add a known correct output to test against + // TODO: Add a known correct output to test against } } diff --git a/google-home/src/traits.rs b/google-home/src/traits.rs index f891539..7322dc7 100644 --- a/google-home/src/traits.rs +++ b/google-home/src/traits.rs @@ -19,7 +19,7 @@ pub trait OnOff: std::fmt::Debug { None } - // @TODO Implement correct error so we can handle them properly + // TODO: Implement correct error so we can handle them properly fn is_on(&self) -> Result; fn set_on(&mut self, on: bool) -> Result<(), ErrorCode>; } diff --git a/src/auth.rs b/src/auth.rs index 8ee6393..916f1dd 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -25,7 +25,7 @@ where let openid = OpenIDConfig::from_ref(state); // Create a request to the auth server - // @TODO Do some discovery to find the correct url for this instead of assuming + // TODO: Do some discovery to find the correct url for this instead of assuming let mut req = reqwest::Client::new() .get(format!("{}/userinfo", openid.base_url)); diff --git a/src/config.rs b/src/config.rs index 6259d84..34359a8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -132,7 +132,7 @@ pub struct KettleConfig { pub struct PresenceDeviceConfig { #[serde(flatten)] pub mqtt: Option, - // @TODO Maybe make this an option? That way if no timeout is set it will immediately turn the + // TODO: Maybe make this an option? That way if no timeout is set it will immediately turn the // device off again? pub timeout: u64 // Timeout in seconds } @@ -145,7 +145,7 @@ impl PresenceDeviceConfig { return Err(MissingWildcard::new(&config.presence.topic).into()); } - // @TODO This is not perfect, if the topic is some/+/thing/# this will fail + // TODO: This is not perfect, if the topic is some/+/thing/# this will fail let offset = config.presence.topic.find('+').or(config.presence.topic.find('#')).unwrap(); let topic = format!("{}/{class}/{identifier}", &config.presence.topic[..offset-1]); trace!("Setting presence mqtt topic: {topic}"); diff --git a/src/devices.rs b/src/devices.rs index aa1f7ba..0187392 100644 --- a/src/devices.rs +++ b/src/devices.rs @@ -31,7 +31,7 @@ pub trait Device: AsGoogleHomeDevice + AsOnMqtt + AsOnPresence + AsOnDarkness + fn get_id(&self) -> &str; } -// @TODO Add an inner type that we can wrap with Arc> to make this type a little bit nicer +// TODO: Add an inner type that we can wrap with Arc> to make this type a little bit nicer // to work with struct Devices { devices: HashMap, @@ -84,7 +84,7 @@ pub enum DevicesError { impl DevicesHandle { - // @TODO Improve error type + // TODO: Improve error type pub async fn fullfillment(&self, google_home: GoogleHome, payload: google_home::Request) -> Result { let (tx, rx) = oneshot::channel(); self.tx.send(Command::Fullfillment { google_home, payload, tx }).await?; @@ -105,7 +105,7 @@ pub fn start(mut mqtt_rx: mqtt::Receiver, mut presence_rx: presence::Receiver, m let (tx, mut rx) = mpsc::channel(100); tokio::spawn(async move { - // @TODO Handle error better + // TODO: Handle error better loop { tokio::select! { Ok(message) = mqtt_rx.recv() => { @@ -119,7 +119,7 @@ pub fn start(mut mqtt_rx: mqtt::Receiver, mut presence_rx: presence::Receiver, m let darkness = *light_sensor_rx.borrow(); devices.on_darkness(darkness).await; } - // @TODO Handle receiving None better, otherwise it might constantly run doing + // TODO: Handle receiving None better, otherwise it might constantly run doing // nothing Some(cmd) = rx.recv() => devices.handle_cmd(cmd) } diff --git a/src/devices/audio_setup.rs b/src/devices/audio_setup.rs index 9f4e25a..52e1379 100644 --- a/src/devices/audio_setup.rs +++ b/src/devices/audio_setup.rs @@ -10,7 +10,7 @@ use crate::presence::OnPresence; use super::{Device, DeviceBox, AsOnOff}; -// @TODO Ideally we store am Arc to the childern devices, +// TODO: Ideally we store am Arc to the childern devices, // that way they hook into everything just like all other devices #[derive(Debug)] pub struct AudioSetup { diff --git a/src/devices/ikea_outlet.rs b/src/devices/ikea_outlet.rs index 5a34fea..1dd616f 100644 --- a/src/devices/ikea_outlet.rs +++ b/src/devices/ikea_outlet.rs @@ -28,7 +28,7 @@ pub struct IkeaOutlet { impl IkeaOutlet { pub async fn build(identifier: &str, info: InfoConfig, mqtt: MqttDeviceConfig, outlet_type: OutletType, timeout: Option, client: AsyncClient) -> Result { - // @TODO Handle potential errors here + // TODO: Handle potential errors here client.subscribe(mqtt.topic.clone(), rumqttc::QoS::AtLeastOnce).await?; Ok(Self{ identifier: identifier.to_owned(), info, mqtt, outlet_type, timeout, client, last_known_state: false, handle: None }) @@ -39,7 +39,7 @@ async fn set_on(client: AsyncClient, topic: &str, on: bool) { let message = OnOffMessage::new(on); let topic = format!("{}/set", topic); - // @TODO Handle potential errors here + // TODO: Handle potential errors here client.publish(topic.clone(), rumqttc::QoS::AtLeastOnce, false, serde_json::to_string(&message).unwrap()) .await .map_err(|err| warn!("Failed to update state on {topic}: {err}")) @@ -89,7 +89,7 @@ impl OnMqtt for IkeaOutlet { }; // Turn the kettle of after the specified timeout - // @TODO Impl Drop for IkeaOutlet that will abort the handle if the IkeaOutlet + // TODO: Impl Drop for IkeaOutlet that will abort the handle if the IkeaOutlet // get dropped let client = self.client.clone(); let topic = self.mqtt.topic.clone(); @@ -99,7 +99,7 @@ impl OnMqtt for IkeaOutlet { debug!(id, "Starting timeout ({timeout:?}) for kettle..."); tokio::time::sleep(timeout).await; debug!(id, "Turning kettle off!"); - // @TODO Idealy we would call self.set_on(false), however since we want to do + // TODO: Idealy we would call self.set_on(false), however since we want to do // it after a timeout we have to put it in a seperate task. // I don't think we can really get around calling outside function set_on(client, &topic, false).await; @@ -147,7 +147,7 @@ impl GoogleHomeDevice for IkeaOutlet { } fn will_report_state(&self) -> bool { - // @TODO Implement state reporting + // TODO: Implement state reporting false } } diff --git a/src/devices/kasa_outlet.rs b/src/devices/kasa_outlet.rs index 93a449e..939d418 100644 --- a/src/devices/kasa_outlet.rs +++ b/src/devices/kasa_outlet.rs @@ -123,7 +123,7 @@ struct Response { system: ResponseSystem, } -// @TODO Improve this error +// TODO: Improve this error #[derive(Debug, Error)] enum ResponseError { #[error("Expected a minimum data length of 4")] diff --git a/src/devices/wake_on_lan.rs b/src/devices/wake_on_lan.rs index 313b24c..c7ef321 100644 --- a/src/devices/wake_on_lan.rs +++ b/src/devices/wake_on_lan.rs @@ -21,7 +21,7 @@ pub struct WakeOnLAN { impl WakeOnLAN { pub async fn build(identifier: &str, info: InfoConfig, mqtt: MqttDeviceConfig, mac_address: MacAddress, broadcast_ip: Ipv4Addr, client: AsyncClient) -> Result { - // @TODO Handle potential errors here + // TODO: Handle potential errors here client.subscribe(mqtt.topic.clone(), rumqttc::QoS::AtLeastOnce).await?; Ok(Self { identifier: identifier.to_owned(), info, mqtt, mac_address, broadcast_ip }) diff --git a/src/error.rs b/src/error.rs index f16cdfd..b52feec 100644 --- a/src/error.rs +++ b/src/error.rs @@ -10,7 +10,7 @@ pub struct MissingEnv { keys: Vec } -// @TODO Would be nice to somehow get the line number of the missing keys +// TODO: Would be nice to somehow get the line number of the missing keys impl MissingEnv { pub fn new() -> Self { Self { keys: Vec::new() } @@ -60,7 +60,7 @@ pub enum ConfigParseError { DeserializeError(#[from] toml::de::Error) } -// @TODO Would be nice to somehow get the line number of the expected wildcard topic +// TODO: Would be nice to somehow get the line number of the expected wildcard topic #[derive(Debug, Error)] #[error("Topic '{topic}' is expected to be a wildcard topic")] pub struct MissingWildcard { diff --git a/src/light_sensor.rs b/src/light_sensor.rs index 7eb5dfb..b47f356 100644 --- a/src/light_sensor.rs +++ b/src/light_sensor.rs @@ -3,7 +3,7 @@ use rumqttc::{matches, AsyncClient}; use tokio::sync::watch; use tracing::{error, trace, debug}; -use crate::{config::{MqttDeviceConfig, LightSensorConfig}, mqtt::{self, OnMqtt, BrightnessMessage}, error::{LightSensorError}}; +use crate::{config::{MqttDeviceConfig, LightSensorConfig}, mqtt::{self, OnMqtt, BrightnessMessage}, error::LightSensorError}; #[async_trait] pub trait OnDarkness { @@ -36,7 +36,7 @@ pub async fn start(mut mqtt_rx: mqtt::Receiver, config: LightSensorConfig, clien tokio::spawn(async move { loop { - // @TODO Handle errors, warn if lagging + // TODO: Handle errors, warn if lagging if let Ok(message) = mqtt_rx.recv().await { light_sensor.on_mqtt(&message).await; } diff --git a/src/presence.rs b/src/presence.rs index d4de5fb..5774ba0 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -42,7 +42,7 @@ pub async fn start(mqtt: MqttDeviceConfig, mut mqtt_rx: mqtt::Receiver, client: tokio::spawn(async move { loop { - // @TODO Handle errors, warn if lagging + // TODO: Handle errors, warn if lagging if let Ok(message) = mqtt_rx.recv().await { presence.on_mqtt(&message).await; }