From 1b965cd45ad1761fa7432d03182451ca57ea000b Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Thu, 22 Dec 2022 05:59:39 +0100 Subject: [PATCH] Request ID is not a UUID like the documentation suggests --- google-home/Cargo.lock | 28 ---------------------------- google-home/Cargo.toml | 7 ------- google-home/src/request.rs | 3 +-- google-home/src/request/execute.rs | 4 +--- google-home/src/request/query.rs | 6 +----- google-home/src/request/sync.rs | 6 +----- google-home/src/response.rs | 5 ++--- google-home/src/response/execute.rs | 4 +--- google-home/src/response/query.rs | 4 +--- google-home/src/response/sync.rs | 4 +--- 10 files changed, 9 insertions(+), 62 deletions(-) diff --git a/google-home/Cargo.lock b/google-home/Cargo.lock index fb18af8..1a81c7a 100644 --- a/google-home/Cargo.lock +++ b/google-home/Cargo.lock @@ -161,17 +161,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "google-home" version = "0.1.0" @@ -182,7 +171,6 @@ dependencies = [ "serde_json", "serde_with", "thiserror", - "uuid", ] [[package]] @@ -489,22 +477,6 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" -[[package]] -name = "uuid" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" -dependencies = [ - "getrandom", - "serde", -] - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "wasm-bindgen" version = "0.2.83" diff --git a/google-home/Cargo.toml b/google-home/Cargo.toml index eeec480..1e7f7f7 100644 --- a/google-home/Cargo.toml +++ b/google-home/Cargo.toml @@ -12,10 +12,3 @@ serde = { version ="1.0.149", features = ["derive"] } serde_json = "1.0.89" serde_with = "2.1.0" thiserror = "1.0.37" - -[dependencies.uuid] -version = "1.2.2" -features = [ - "v4", - "serde", -] diff --git a/google-home/src/request.rs b/google-home/src/request.rs index 1b2c873..b0cda09 100644 --- a/google-home/src/request.rs +++ b/google-home/src/request.rs @@ -3,7 +3,6 @@ pub mod query; pub mod execute; use serde::Deserialize; -use uuid::Uuid; #[derive(Debug, Deserialize)] #[serde(tag = "intent", content = "payload")] @@ -19,6 +18,6 @@ pub enum Intent { #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Request { - pub request_id: Uuid, + pub request_id: String, pub inputs: Vec, } diff --git a/google-home/src/request/execute.rs b/google-home/src/request/execute.rs index 5c5f77c..92b1668 100644 --- a/google-home/src/request/execute.rs +++ b/google-home/src/request/execute.rs @@ -35,8 +35,6 @@ pub enum CommandType { #[cfg(test)] mod tests { - use std::str::FromStr; - use uuid::Uuid; use super::*; use crate::request::{Request, Intent}; @@ -88,7 +86,7 @@ mod tests { println!("{:?}", req); - assert_eq!(req.request_id, Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap()); + assert_eq!(req.request_id, "ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned()); assert_eq!(req.inputs.len(), 1); match &req.inputs[0] { Intent::Execute(payload) => { diff --git a/google-home/src/request/query.rs b/google-home/src/request/query.rs index da79bdb..93d8d5f 100644 --- a/google-home/src/request/query.rs +++ b/google-home/src/request/query.rs @@ -15,10 +15,6 @@ pub struct Device { #[cfg(test)] mod tests { - use std::str::FromStr; - - use uuid::Uuid; - use crate::request::{Request, Intent}; #[test] @@ -57,7 +53,7 @@ mod tests { println!("{:?}", req); - assert_eq!(req.request_id, Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap()); + assert_eq!(req.request_id, "ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned()); assert_eq!(req.inputs.len(), 1); match &req.inputs[0] { Intent::Query(payload) => { diff --git a/google-home/src/request/sync.rs b/google-home/src/request/sync.rs index e19c7d6..f610d67 100644 --- a/google-home/src/request/sync.rs +++ b/google-home/src/request/sync.rs @@ -1,9 +1,5 @@ #[cfg(test)] mod tests { - use std::str::FromStr; - - use uuid::Uuid; - use crate::request::{Request, Intent}; #[test] @@ -22,7 +18,7 @@ mod tests { println!("{:?}", req); - assert_eq!(req.request_id, Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap()); + assert_eq!(req.request_id, "ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned()); assert_eq!(req.inputs.len(), 1); match req.inputs[0] { Intent::Sync => {}, diff --git a/google-home/src/response.rs b/google-home/src/response.rs index 976dd1c..e4b79a0 100644 --- a/google-home/src/response.rs +++ b/google-home/src/response.rs @@ -4,17 +4,16 @@ pub mod execute; use serde::Serialize; use serde_with::skip_serializing_none; -use uuid::Uuid; #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] pub struct Response { - request_id: Uuid, + request_id: String, payload: ResponsePayload, } impl Response { - pub fn new(request_id: Uuid, payload: ResponsePayload) -> Self { + pub fn new(request_id: String, payload: ResponsePayload) -> Self { Self { request_id, payload } } } diff --git a/google-home/src/response/execute.rs b/google-home/src/response/execute.rs index b497fa5..665cfb4 100644 --- a/google-home/src/response/execute.rs +++ b/google-home/src/response/execute.rs @@ -70,8 +70,6 @@ pub enum Status { #[cfg(test)] mod tests { - use std::str::FromStr; - use uuid::Uuid; use super::*; use crate::{response::{Response, ResponsePayload, State}, errors::DeviceError}; @@ -94,7 +92,7 @@ mod tests { command.ids.push("456".into()); execute_resp.add_command(command); - let resp = Response::new(Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap(), ResponsePayload::Execute(execute_resp)); + let resp = Response::new("ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned(), ResponsePayload::Execute(execute_resp)); let json = serde_json::to_string(&resp).unwrap(); diff --git a/google-home/src/response/query.rs b/google-home/src/response/query.rs index ab56a8e..af24b3d 100644 --- a/google-home/src/response/query.rs +++ b/google-home/src/response/query.rs @@ -66,8 +66,6 @@ impl Device { #[cfg(test)] mod tests { - use std::str::FromStr; - use uuid::Uuid; use super::*; use crate::response::{Response, ResponsePayload}; @@ -83,7 +81,7 @@ mod tests { device.state.on = Some(false); query_resp.add_device("456", device); - let resp = Response::new(Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap(), ResponsePayload::Query(query_resp)); + let resp = Response::new("ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned(), ResponsePayload::Query(query_resp)); let json = serde_json::to_string(&resp).unwrap(); diff --git a/google-home/src/response/sync.rs b/google-home/src/response/sync.rs index d3fee82..2f3820b 100644 --- a/google-home/src/response/sync.rs +++ b/google-home/src/response/sync.rs @@ -61,8 +61,6 @@ impl Device { #[cfg(test)] mod tests { - use std::str::FromStr; - use uuid::Uuid; use super::*; use crate::{response::{Response, ResponsePayload}, types::Type, traits::Trait}; @@ -85,7 +83,7 @@ mod tests { sync_resp.add_device(device); - let resp = Response::new(Uuid::from_str("ff36a3cc-ec34-11e6-b1a0-64510650abcf").unwrap(), ResponsePayload::Sync(sync_resp)); + let resp = Response::new("ff36a3cc-ec34-11e6-b1a0-64510650abcf".to_owned(), ResponsePayload::Sync(sync_resp)); let json = serde_json::to_string(&resp).unwrap();