Buttplug sex toy control library
20
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: device config should use refs as arguments

+23 -23
+6 -6
buttplug/src/util/device_configuration.rs
··· 435 435 } 436 436 437 437 fn load_protocol_configs_internal( 438 - main_config_str: Option<String>, 439 - user_config_str: Option<String>, 438 + main_config_str: &Option<String>, 439 + user_config_str: &Option<String>, 440 440 skip_version_check: bool, 441 441 ) -> Result<ExternalDeviceConfiguration, ButtplugDeviceError> { 442 442 if main_config_str.is_some() { ··· 446 446 } 447 447 // Start by loading the main config 448 448 let main_config = load_protocol_config_from_json::<ProtocolConfiguration>( 449 - &main_config_str.unwrap_or_else(|| DEVICE_CONFIGURATION_JSON.to_owned()), 449 + &main_config_str.as_ref().unwrap_or(&DEVICE_CONFIGURATION_JSON.to_owned()), 450 450 skip_version_check, 451 451 )?; 452 452 ··· 497 497 } 498 498 499 499 pub fn load_protocol_configs( 500 - main_config_str: Option<String>, 501 - user_config_str: Option<String>, 500 + main_config_str: &Option<String>, 501 + user_config_str: &Option<String>, 502 502 skip_version_check: bool, 503 503 ) -> Result<DeviceConfigurationManagerBuilder, ButtplugDeviceError> { 504 504 let mut dcm_builder = DeviceConfigurationManagerBuilder::default(); ··· 524 524 } 525 525 526 526 pub fn create_test_dcm(allow_raw_messages: bool) -> DeviceConfigurationManager { 527 - let devices = load_protocol_configs_internal(None, None, false) 527 + let devices = load_protocol_configs_internal(&None, &None, false) 528 528 .expect("If this fails, the whole library goes with it."); 529 529 let mut builder = DeviceConfigurationManagerBuilder::default(); 530 530 if allow_raw_messages {
+15 -15
buttplug/tests/test_device_config.rs
··· 88 88 #[tokio::test] 89 89 async fn test_valid_null_version_config() { 90 90 assert!( 91 - load_protocol_configs(None, Some(BASE_VALID_VERSION_CONFIG_JSON.to_owned()), false).is_ok() 91 + load_protocol_configs(&None, &Some(BASE_VALID_VERSION_CONFIG_JSON.to_owned()), false).is_ok() 92 92 ); 93 93 } 94 94 ··· 96 96 #[tokio::test] 97 97 async fn test_valid_null_user_config() { 98 98 assert!(load_protocol_configs( 99 - None, 100 - Some(BASE_VALID_NULL_USER_CONFIG_JSON.to_owned()), 99 + &None, 100 + &Some(BASE_VALID_NULL_USER_CONFIG_JSON.to_owned()), 101 101 false 102 102 ) 103 103 .is_ok()); ··· 107 107 #[tokio::test] 108 108 async fn test_invalid_null_version_config() { 109 109 assert!(load_protocol_configs( 110 - None, 111 - Some(BASE_INVALID_VERSION_CONFIG_JSON.to_owned()), 110 + &None, 111 + &Some(BASE_INVALID_VERSION_CONFIG_JSON.to_owned()), 112 112 false 113 113 ) 114 114 .is_err()); ··· 118 118 #[tokio::test] 119 119 #[ignore = "Still need to update for new message format"] 120 120 async fn test_basic_device_config() { 121 - assert!(load_protocol_configs(Some(BASE_CONFIG_JSON.to_owned()), None, false).is_ok()); 121 + assert!(load_protocol_configs(&Some(BASE_CONFIG_JSON.to_owned()), &None, false).is_ok()); 122 122 } 123 123 124 124 #[cfg(feature = "server")] ··· 186 186 } 187 187 }"#; 188 188 assert!(load_protocol_configs( 189 - Some(BASE_CONFIG_JSON.to_owned()), 190 - Some(user_config_json.to_owned()), 189 + &Some(BASE_CONFIG_JSON.to_owned()), 190 + &Some(user_config_json.to_owned()), 191 191 false 192 192 ) 193 193 .is_err()); ··· 254 254 } 255 255 "#; 256 256 assert!(load_protocol_configs( 257 - Some(BASE_CONFIG_JSON.to_owned()), 258 - Some(user_config_json.to_owned()), 257 + &Some(BASE_CONFIG_JSON.to_owned()), 258 + &Some(user_config_json.to_owned()), 259 259 false 260 260 ) 261 261 .is_err()); ··· 263 263 264 264 #[tokio::test] 265 265 async fn test_server_builder_null_device_config() { 266 - assert!(load_protocol_configs(None, None, false).is_ok()) 266 + assert!(load_protocol_configs(&None, &None, false).is_ok()) 267 267 } 268 268 269 269 #[tokio::test] 270 270 async fn test_server_builder_device_config_invalid_json() { 271 - assert!(load_protocol_configs(Some("{\"Not Valid JSON\"}".to_owned()), None, false).is_err()) 271 + assert!(load_protocol_configs(&Some("{\"Not Valid JSON\"}".to_owned()), &None, false).is_err()) 272 272 } 273 273 274 274 #[tokio::test] ··· 283 283 "protocols": {} 284 284 } 285 285 "#; 286 - assert!(load_protocol_configs(Some(device_json.to_owned()), None, false).is_err()); 286 + assert!(load_protocol_configs(&Some(device_json.to_owned()), &None, false).is_err()); 287 287 } 288 288 289 289 #[tokio::test] ··· 297 297 "protocols": {} 298 298 } 299 299 "#; 300 - assert!(load_protocol_configs(None, Some(device_json.to_owned()), false).is_err()); 300 + assert!(load_protocol_configs(&None, &Some(device_json.to_owned()), false).is_err()); 301 301 } 302 302 303 303 #[tokio::test] 304 304 async fn test_server_builder_user_device_config_invalid_json() { 305 - assert!(load_protocol_configs(None, Some("{\"Not Valid JSON\"}".to_owned()), false).is_err()) 305 + assert!(load_protocol_configs(&None, &Some("{\"Not Valid JSON\"}".to_owned()), false).is_err()) 306 306 }
+1 -1
buttplug/tests/util/device_test/client/client_v2/mod.rs
··· 121 121 None 122 122 }; 123 123 124 - let dcm = load_protocol_configs(base_cfg, user_cfg, false) 124 + let dcm = load_protocol_configs(&base_cfg, &user_cfg, false) 125 125 .unwrap() 126 126 .finish() 127 127 .unwrap();
+1 -1
buttplug/tests/util/device_test/client/client_v3/mod.rs
··· 130 130 None 131 131 }; 132 132 133 - let dcm = load_protocol_configs(base_cfg, user_cfg, false) 133 + let dcm = load_protocol_configs(&base_cfg, &user_cfg, false) 134 134 .unwrap() 135 135 .finish() 136 136 .unwrap();