Changed how TODO notes are marked to properly highlight in vim

This commit is contained in:
Dreaded_X 2023-04-09 23:01:21 +02:00
parent 1a9d12b1f3
commit 3613c2cbdf
Signed by: Dreaded_X
GPG Key ID: FA5F485356B0D2D4
14 changed files with 26 additions and 26 deletions

View File

@ -22,7 +22,7 @@ impl GoogleHome {
}
pub fn handle_request(&self, request: Request, mut devices: &mut HashMap<&str, &mut dyn GoogleHomeDevice>) -> Result<Response, FullfillmentError> {
// @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::<Result<Vec<_>, 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 {

View File

@ -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
}
}

View File

@ -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
}
}

View File

@ -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<bool, ErrorCode>;
fn set_on(&mut self, on: bool) -> Result<(), ErrorCode>;
}

View File

@ -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));

View File

@ -132,7 +132,7 @@ pub struct KettleConfig {
pub struct PresenceDeviceConfig {
#[serde(flatten)]
pub mqtt: Option<MqttDeviceConfig>,
// @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}");

View File

@ -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<RwLock<>> to make this type a little bit nicer
// TODO: Add an inner type that we can wrap with Arc<RwLock<>> to make this type a little bit nicer
// to work with
struct Devices {
devices: HashMap<String, DeviceBox>,
@ -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<google_home::Response, DevicesError> {
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)
}

View File

@ -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 {

View File

@ -28,7 +28,7 @@ pub struct IkeaOutlet {
impl IkeaOutlet {
pub async fn build(identifier: &str, info: InfoConfig, mqtt: MqttDeviceConfig, outlet_type: OutletType, timeout: Option<u64>, client: AsyncClient) -> Result<Self, DeviceError> {
// @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
}
}

View File

@ -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")]

View File

@ -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<Self, DeviceError> {
// @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 })

View File

@ -10,7 +10,7 @@ pub struct MissingEnv {
keys: Vec<String>
}
// @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 {

View File

@ -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;
}

View File

@ -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;
}