Request ID is not a UUID like the documentation suggests
This commit is contained in:
parent
2103a46416
commit
1b965cd45a
28
google-home/Cargo.lock
generated
28
google-home/Cargo.lock
generated
|
@ -161,17 +161,6 @@ version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
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]]
|
[[package]]
|
||||||
name = "google-home"
|
name = "google-home"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -182,7 +171,6 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"uuid",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -489,22 +477,6 @@ version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
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]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.83"
|
version = "0.2.83"
|
||||||
|
|
|
@ -12,10 +12,3 @@ serde = { version ="1.0.149", features = ["derive"] }
|
||||||
serde_json = "1.0.89"
|
serde_json = "1.0.89"
|
||||||
serde_with = "2.1.0"
|
serde_with = "2.1.0"
|
||||||
thiserror = "1.0.37"
|
thiserror = "1.0.37"
|
||||||
|
|
||||||
[dependencies.uuid]
|
|
||||||
version = "1.2.2"
|
|
||||||
features = [
|
|
||||||
"v4",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ pub mod query;
|
||||||
pub mod execute;
|
pub mod execute;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(tag = "intent", content = "payload")]
|
#[serde(tag = "intent", content = "payload")]
|
||||||
|
@ -19,6 +18,6 @@ pub enum Intent {
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
pub request_id: Uuid,
|
pub request_id: String,
|
||||||
pub inputs: Vec<Intent>,
|
pub inputs: Vec<Intent>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ pub enum CommandType {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
|
||||||
use uuid::Uuid;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::request::{Request, Intent};
|
use crate::request::{Request, Intent};
|
||||||
|
|
||||||
|
@ -88,7 +86,7 @@ mod tests {
|
||||||
|
|
||||||
println!("{:?}", req);
|
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);
|
assert_eq!(req.inputs.len(), 1);
|
||||||
match &req.inputs[0] {
|
match &req.inputs[0] {
|
||||||
Intent::Execute(payload) => {
|
Intent::Execute(payload) => {
|
||||||
|
|
|
@ -15,10 +15,6 @@ pub struct Device {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::request::{Request, Intent};
|
use crate::request::{Request, Intent};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -57,7 +53,7 @@ mod tests {
|
||||||
|
|
||||||
println!("{:?}", req);
|
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);
|
assert_eq!(req.inputs.len(), 1);
|
||||||
match &req.inputs[0] {
|
match &req.inputs[0] {
|
||||||
Intent::Query(payload) => {
|
Intent::Query(payload) => {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::request::{Request, Intent};
|
use crate::request::{Request, Intent};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -22,7 +18,7 @@ mod tests {
|
||||||
|
|
||||||
println!("{:?}", req);
|
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);
|
assert_eq!(req.inputs.len(), 1);
|
||||||
match req.inputs[0] {
|
match req.inputs[0] {
|
||||||
Intent::Sync => {},
|
Intent::Sync => {},
|
||||||
|
|
|
@ -4,17 +4,16 @@ pub mod execute;
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_with::skip_serializing_none;
|
use serde_with::skip_serializing_none;
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
request_id: Uuid,
|
request_id: String,
|
||||||
payload: ResponsePayload,
|
payload: ResponsePayload,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
pub fn new(request_id: Uuid, payload: ResponsePayload) -> Self {
|
pub fn new(request_id: String, payload: ResponsePayload) -> Self {
|
||||||
Self { request_id, payload }
|
Self { request_id, payload }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,6 @@ pub enum Status {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
|
||||||
use uuid::Uuid;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{response::{Response, ResponsePayload, State}, errors::DeviceError};
|
use crate::{response::{Response, ResponsePayload, State}, errors::DeviceError};
|
||||||
|
|
||||||
|
@ -94,7 +92,7 @@ mod tests {
|
||||||
command.ids.push("456".into());
|
command.ids.push("456".into());
|
||||||
execute_resp.add_command(command);
|
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();
|
let json = serde_json::to_string(&resp).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -66,8 +66,6 @@ impl Device {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
|
||||||
use uuid::Uuid;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::response::{Response, ResponsePayload};
|
use crate::response::{Response, ResponsePayload};
|
||||||
|
|
||||||
|
@ -83,7 +81,7 @@ mod tests {
|
||||||
device.state.on = Some(false);
|
device.state.on = Some(false);
|
||||||
query_resp.add_device("456", device);
|
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();
|
let json = serde_json::to_string(&resp).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,6 @@ impl Device {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::str::FromStr;
|
|
||||||
use uuid::Uuid;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{response::{Response, ResponsePayload}, types::Type, traits::Trait};
|
use crate::{response::{Response, ResponsePayload}, types::Type, traits::Trait};
|
||||||
|
|
||||||
|
@ -85,7 +83,7 @@ mod tests {
|
||||||
|
|
||||||
sync_resp.add_device(device);
|
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();
|
let json = serde_json::to_string(&resp).unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user