From dfeee752973a15ee4b0f0be7e685887edfd272d8 Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Mon, 20 Dec 2021 14:14:54 -0800 Subject: [PATCH] changed json keys from "button" -> "update --- src/modules/stream_states/state_update.rs | 8 ++--- src/tests/state_update_tests.rs | 40 +++++++++++------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/modules/stream_states/state_update.rs b/src/modules/stream_states/state_update.rs index 318d20e..6ae8e07 100644 --- a/src/modules/stream_states/state_update.rs +++ b/src/modules/stream_states/state_update.rs @@ -25,8 +25,8 @@ impl StateUpdate { let message_type = &incoming_json["type"]; match message_type.as_str().unwrap() { - "button" => { - let value = &incoming_json["button"]; + "update" => { + let value = &incoming_json["update"]; match value.as_str().unwrap() { //Master Scenes "Scene_Camera" => {StateUpdate::Scene(Scenes::Camera)} @@ -96,8 +96,8 @@ impl StateUpdate { StateUpdate::UpdateClient => todo!(), }; serde_json::json!({ - "type": "button", - "button": update_type, + "type": "update", + "update": update_type, "data": data, }) } diff --git a/src/tests/state_update_tests.rs b/src/tests/state_update_tests.rs index af1afcd..10d09ef 100644 --- a/src/tests/state_update_tests.rs +++ b/src/tests/state_update_tests.rs @@ -5,83 +5,83 @@ use crate::modules::stream_states::{state_update::StateUpdate, enums::{Scenes, S #[test] fn test_json_to_state_update() { assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Scene_Camera\"}" + "{\"type\": \"update\", \"update\": \"Scene_Camera\"}" ).unwrap()), StateUpdate::Scene(Scenes::Camera)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Scene_Screen\"}" + "{\"type\": \"update\", \"update\": \"Scene_Screen\"}" ).unwrap()), StateUpdate::Scene(Scenes::Screen)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Augmented\", \"data\": true}" + "{\"type\": \"update\", \"update\": \"Augmented\", \"data\": true}" ).unwrap()), StateUpdate::SceneIsAugmented(true)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Auto_Change_To_Camera\", \"data\": true}" + "{\"type\": \"update\", \"update\": \"Auto_Change_To_Camera\", \"data\": true}" ).unwrap()), StateUpdate::TimerCanRun(true)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Auto_Change_To_Camera\", \"data\": false}" + "{\"type\": \"update\", \"update\": \"Auto_Change_To_Camera\", \"data\": false}" ).unwrap()), StateUpdate::TimerCanRun(false)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Change_With_Clicker\", \"data\": true}" + "{\"type\": \"update\", \"update\": \"Change_With_Clicker\", \"data\": true}" ).unwrap()), StateUpdate::ChangeSceneOnChangeSlide(true)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Change_With_Clicker\", \"data\": false}" + "{\"type\": \"update\", \"update\": \"Change_With_Clicker\", \"data\": false}" ).unwrap()), StateUpdate::ChangeSceneOnChangeSlide(false)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Toggle_Computer_Volume\", \"data\": true}" + "{\"type\": \"update\", \"update\": \"Toggle_Computer_Volume\", \"data\": true}" ).unwrap()), StateUpdate::ComputerSoundIsOn(true)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Toggle_Computer_Volume\", \"data\": false}" + "{\"type\": \"update\", \"update\": \"Toggle_Computer_Volume\", \"data\": false}" ).unwrap()), StateUpdate::ComputerSoundIsOn(false)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Toggle_Stream_Volume\", \"data\": true}" + "{\"type\": \"update\", \"update\": \"Toggle_Stream_Volume\", \"data\": true}" ).unwrap()), StateUpdate::StreamIsMuted(true)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Toggle_Stream_Volume\", \"data\": false}" + "{\"type\": \"update\", \"update\": \"Toggle_Stream_Volume\", \"data\": false}" ).unwrap()), StateUpdate::StreamIsMuted(false)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Media_Pause_Play\", \"data\": true}" + "{\"type\": \"update\", \"update\": \"Media_Pause_Play\", \"data\": true}" ).unwrap()), StateUpdate::ComputerMediaDoPause(true)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Media_Pause_Play\", \"data\": false}" + "{\"type\": \"update\", \"update\": \"Media_Pause_Play\", \"data\": false}" ).unwrap()), StateUpdate::ComputerMediaDoPause(false)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Camera_None\"}" + "{\"type\": \"update\", \"update\": \"Camera_None\"}" ).unwrap()), StateUpdate::SubScene(SubScenes::CameraDefault)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Camera_Top_Right\"}" + "{\"type\": \"update\", \"update\": \"Camera_Top_Right\"}" ).unwrap()), StateUpdate::SubScene(SubScenes::CameraWithUpperRight)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Camera_Bottom_Right\"}" + "{\"type\": \"update\", \"update\": \"Camera_Bottom_Right\"}" ).unwrap()), StateUpdate::SubScene(SubScenes::CameraWithLowerRight)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Camera_Bottom_Left\"}" + "{\"type\": \"update\", \"update\": \"Camera_Bottom_Left\"}" ).unwrap()), StateUpdate::SubScene(SubScenes::CameraWithLargeUpperRight)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Screen_None\"}" + "{\"type\": \"update\", \"update\": \"Screen_None\"}" ).unwrap()), StateUpdate::SubScene(SubScenes::ScreenDefault)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Screen_Top_Right\"}" + "{\"type\": \"update\", \"update\": \"Screen_Top_Right\"}" ).unwrap()), StateUpdate::SubScene(SubScenes::ScreenWithUpperRight)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( - "{\"type\": \"button\", \"button\": \"Screen_Bottom_Right\"}" + "{\"type\": \"update\", \"update\": \"Screen_Bottom_Right\"}" ).unwrap()), StateUpdate::SubScene(SubScenes::ScreenWithLowerRight)); assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(