Buttplug sex toy control library

chore: Warnings cleanup

+37 -49
+7 -7
crates/buttplug_server/src/device/protocol.rs
··· 227 let output_command = cmd.output_command(); 228 match output_command { 229 OutputCommand::Constrict(x) => { 230 - self.handle_output_constrict_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|e| ButtplugDeviceError::DeviceCommandSignError)?) 231 } 232 OutputCommand::Spray(x) => { 233 - self.handle_output_spray_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|e| ButtplugDeviceError::DeviceCommandSignError)?) 234 } 235 OutputCommand::Oscillate(x) => { 236 - self.handle_output_oscillate_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|e| ButtplugDeviceError::DeviceCommandSignError)?) 237 } 238 OutputCommand::Rotate(x) => { 239 self.handle_output_rotate_cmd(cmd.feature_index(), cmd.feature_id(), x.value()) 240 } 241 OutputCommand::Vibrate(x) => { 242 - self.handle_output_vibrate_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|e| ButtplugDeviceError::DeviceCommandSignError)?) 243 } 244 OutputCommand::Position(x) => { 245 - self.handle_output_position_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|e| ButtplugDeviceError::DeviceCommandSignError)?) 246 } 247 OutputCommand::Heater(x) => { 248 - self.handle_output_heater_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|e| ButtplugDeviceError::DeviceCommandSignError)?) 249 } 250 OutputCommand::Led(x) => { 251 - self.handle_output_led_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|e| ButtplugDeviceError::DeviceCommandSignError)?) 252 } 253 OutputCommand::PositionWithDuration(x) => self.handle_position_with_duration_cmd( 254 cmd.feature_index(),
··· 227 let output_command = cmd.output_command(); 228 match output_command { 229 OutputCommand::Constrict(x) => { 230 + self.handle_output_constrict_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?) 231 } 232 OutputCommand::Spray(x) => { 233 + self.handle_output_spray_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?) 234 } 235 OutputCommand::Oscillate(x) => { 236 + self.handle_output_oscillate_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?) 237 } 238 OutputCommand::Rotate(x) => { 239 self.handle_output_rotate_cmd(cmd.feature_index(), cmd.feature_id(), x.value()) 240 } 241 OutputCommand::Vibrate(x) => { 242 + self.handle_output_vibrate_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?) 243 } 244 OutputCommand::Position(x) => { 245 + self.handle_output_position_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?) 246 } 247 OutputCommand::Heater(x) => { 248 + self.handle_output_heater_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?) 249 } 250 OutputCommand::Led(x) => { 251 + self.handle_output_led_cmd(cmd.feature_index(), cmd.feature_id(), x.value().try_into().map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?) 252 } 253 OutputCommand::PositionWithDuration(x) => self.handle_position_with_duration_cmd( 254 cmd.feature_index(),
+3 -3
crates/buttplug_server/src/device/protocol_impl/fredorch.rs
··· 184 } 185 } 186 187 - const speed_matrix: [[u32; 20]; 15] = [ 188 // distance, speed 1-20 189 /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ 190 /* 1*/ [1000, 800, 400, 235, 200, 172, 155, 92, 60, 45, 38, 34, 32, 28, 27, 26, 25, 24, 23, 22 ], ··· 204 /*15*/ [8048, 7068, 4442, 3708, 2668, 1930, 1800, 1520, 878, 618, 428, 365, 260, 255, 250, 240, 230, 220, 210, 200], 205 ]; 206 207 - fn calculate_speed(mut distance: u32, duration: u32) -> u8 { 208 let distance = distance.clamp(0,15); 209 if distance == 0 {return 0;} 210 211 let mut speed= 1; 212 while speed < 20 { 213 - if speed_matrix[distance as usize - 1][speed as usize - 1] < duration { 214 return speed; 215 } 216 speed += 1;
··· 184 } 185 } 186 187 + const SPEED_MATRIX: [[u32; 20]; 15] = [ 188 // distance, speed 1-20 189 /* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ 190 /* 1*/ [1000, 800, 400, 235, 200, 172, 155, 92, 60, 45, 38, 34, 32, 28, 27, 26, 25, 24, 23, 22 ], ··· 204 /*15*/ [8048, 7068, 4442, 3708, 2668, 1930, 1800, 1520, 878, 618, 428, 365, 260, 255, 250, 240, 230, 220, 210, 200], 205 ]; 206 207 + fn calculate_speed(distance: u32, duration: u32) -> u8 { 208 let distance = distance.clamp(0,15); 209 if distance == 0 {return 0;} 210 211 let mut speed= 1; 212 while speed < 20 { 213 + if SPEED_MATRIX[distance as usize - 1][speed as usize - 1] < duration { 214 return speed; 215 } 216 speed += 1;
+15 -10
crates/buttplug_server/src/device/protocol_impl/galaku.rs
··· 62 new_data 63 } 64 65 fn decrypt(data: Vec<u32>) -> Vec<u32> { 66 let mut new_data = vec![data[0]]; 67 for i in 1..data.len() { ··· 72 new_data 73 } 74 75 - fn send_bytes(data: Vec<u32>) -> Vec<u8> { 76 - let mut new_data = vec![35]; 77 - new_data.extend(data); 78 - new_data.push(new_data.iter().sum()); 79 - let mut uint8_array: Vec<u8> = Vec::new(); 80 - for value in encrypt(new_data) { 81 - uint8_array.push(value as u8); 82 - } 83 - uint8_array 84 - } 85 86 fn read_value(data: Vec<u8>) -> u32 { 87 let mut uint32_data: Vec<u32> = Vec::new(); ··· 95 0 96 } 97 } 98 99 const GALAKU_PROTOCOL_UUID: Uuid = uuid!("766d15d5-0f43-4768-a73a-96ff48bc389e"); 100 generic_protocol_initializer_setup!(Galaku, "galaku");
··· 62 new_data 63 } 64 65 + fn send_bytes(data: Vec<u32>) -> Vec<u8> { 66 + let mut new_data = vec![35]; 67 + new_data.extend(data); 68 + new_data.push(new_data.iter().sum()); 69 + let mut uint8_array: Vec<u8> = Vec::new(); 70 + for value in encrypt(new_data) { 71 + uint8_array.push(value as u8); 72 + } 73 + uint8_array 74 + } 75 + 76 + /* 77 + 78 fn decrypt(data: Vec<u32>) -> Vec<u32> { 79 let mut new_data = vec![data[0]]; 80 for i in 1..data.len() { ··· 85 new_data 86 } 87 88 89 fn read_value(data: Vec<u8>) -> u32 { 90 let mut uint32_data: Vec<u32> = Vec::new(); ··· 98 0 99 } 100 } 101 + 102 + */ 103 104 const GALAKU_PROTOCOL_UUID: Uuid = uuid!("766d15d5-0f43-4768-a73a-96ff48bc389e"); 105 generic_protocol_initializer_setup!(Galaku, "galaku");
+1 -1
crates/buttplug_server/src/device/protocol_impl/kiiroo_powershot.rs
··· 62 device: Arc<Hardware>, 63 feature_index: u32, 64 feature_id: Uuid, 65 - ) -> BoxFuture<Result<InputReadingV4, ButtplugDeviceError>> { 66 debug!("Trying to get battery reading."); 67 let msg = HardwareReadCmd::new(feature_id, Endpoint::RxBLEBattery, 20, 0); 68 let fut = device.read_value(&msg);
··· 62 device: Arc<Hardware>, 63 feature_index: u32, 64 feature_id: Uuid, 65 + ) -> BoxFuture<'_, Result<InputReadingV4, ButtplugDeviceError>> { 66 debug!("Trying to get battery reading."); 67 let msg = HardwareReadCmd::new(feature_id, Endpoint::RxBLEBattery, 20, 0); 68 let fut = device.read_value(&msg);
+3 -3
crates/buttplug_server/src/device/protocol_impl/kiiroo_v21.rs
··· 19 util::stream::convert_broadcast_receiver_to_stream, 20 }; 21 use buttplug_server_device_config::Endpoint; 22 - use dashmap::DashSet; 23 use futures::{FutureExt, StreamExt, future::BoxFuture}; 24 use std::{ 25 default::Default, ··· 37 pub struct KiirooV21 { 38 previous_position: Arc<AtomicU8>, 39 // Set of sensors we've subscribed to for updates. 40 - subscribed_sensors: Arc<DashSet<u32>>, 41 event_stream: broadcast::Sender<ButtplugServerDeviceMessage>, 42 } 43 ··· 46 let (sender, _) = broadcast::channel(256); 47 Self { 48 previous_position: Default::default(), 49 - subscribed_sensors: Arc::new(DashSet::new()), 50 event_stream: sender, 51 } 52 }
··· 19 util::stream::convert_broadcast_receiver_to_stream, 20 }; 21 use buttplug_server_device_config::Endpoint; 22 + // use dashmap::DashSet; 23 use futures::{FutureExt, StreamExt, future::BoxFuture}; 24 use std::{ 25 default::Default, ··· 37 pub struct KiirooV21 { 38 previous_position: Arc<AtomicU8>, 39 // Set of sensors we've subscribed to for updates. 40 + // subscribed_sensors: Arc<DashSet<u32>>, 41 event_stream: broadcast::Sender<ButtplugServerDeviceMessage>, 42 } 43 ··· 46 let (sender, _) = broadcast::channel(256); 47 Self { 48 previous_position: Default::default(), 49 + // subscribed_sensors: Arc::new(DashSet::new()), 50 event_stream: sender, 51 } 52 }
+2 -7
crates/buttplug_server/src/device/protocol_impl/lovense/lovense_rotate_vibrator.rs
··· 13 }; 14 use buttplug_core::{errors::ButtplugDeviceError, message::InputReadingV4}; 15 use futures::future::BoxFuture; 16 - use std::sync::{ 17 - Arc, 18 - atomic::{AtomicBool, Ordering}, 19 - }; 20 use uuid::Uuid; 21 22 #[derive(Default)] 23 - pub struct LovenseRotateVibrator { 24 - clockwise: AtomicBool, 25 - } 26 27 impl ProtocolHandler for LovenseRotateVibrator { 28 fn keepalive_strategy(&self) -> ProtocolKeepaliveStrategy {
··· 13 }; 14 use buttplug_core::{errors::ButtplugDeviceError, message::InputReadingV4}; 15 use futures::future::BoxFuture; 16 + use std::sync::Arc; 17 use uuid::Uuid; 18 19 #[derive(Default)] 20 + pub struct LovenseRotateVibrator {} 21 22 impl ProtocolHandler for LovenseRotateVibrator { 23 fn keepalive_strategy(&self) -> ProtocolKeepaliveStrategy {
+1 -1
crates/buttplug_server/src/device/protocol_impl/lovense/mod.rs
··· 234 235 // New Lovense devices seem to be moving to the simplified LVS:<bytearray>; command format. 236 // I'm not sure if there's a good way to detect this. 237 - let use_lvs = device_type == "OC"; 238 239 debug!( 240 "Device type {} initialized with {} vibrators {} using Mply",
··· 234 235 // New Lovense devices seem to be moving to the simplified LVS:<bytearray>; command format. 236 // I'm not sure if there's a good way to detect this. 237 + //let use_lvs = device_type == "OC"; 238 239 debug!( 240 "Device type {} initialized with {} vibrators {} using Mply",
+2
crates/buttplug_server/src/message/v1/spec_enums.rs
··· 144 } 145 } 146 147 #[derive(Copy, Debug, Clone, PartialEq, Eq, Hash, Display, Serialize, Deserialize)] 148 pub enum ButtplugDeviceMessageNameV1 { 149 VibrateCmd,
··· 144 } 145 } 146 147 + // Leave this in for consistency sake, mostly for implementing backward compat tests 148 + #[allow(dead_code)] 149 #[derive(Copy, Debug, Clone, PartialEq, Eq, Hash, Display, Serialize, Deserialize)] 150 pub enum ButtplugDeviceMessageNameV1 { 151 VibrateCmd,
+1 -1
crates/buttplug_server/src/message/v3/client_device_message_attributes.rs
··· 10 v2::{ClientDeviceMessageAttributesV2, GenericDeviceMessageAttributesV2}, 11 }; 12 use buttplug_core::message::{ 13 - DeviceFeature, DeviceFeatureOutputLimits, DeviceFeatureOutputValueProperties, InputCommandType, InputType, OutputType 14 }; 15 use getset::{Getters, MutGetters, Setters}; 16 use serde::{Deserialize, Serialize, Serializer, ser::SerializeSeq};
··· 10 v2::{ClientDeviceMessageAttributesV2, GenericDeviceMessageAttributesV2}, 11 }; 12 use buttplug_core::message::{ 13 + DeviceFeature, DeviceFeatureOutputValueProperties, InputCommandType, InputType, OutputType 14 }; 15 use getset::{Getters, MutGetters, Setters}; 16 use serde::{Deserialize, Serialize, Serializer, ser::SerializeSeq};
-12
crates/buttplug_server_device_config/src/device_config_file/base.rs
··· 34 self.version 35 } 36 } 37 - 38 - impl BaseConfigFile { 39 - pub(crate) fn new(major_version: u32, minor_version: u32) -> Self { 40 - Self { 41 - version: ConfigVersion { 42 - major: major_version, 43 - minor: minor_version, 44 - }, 45 - protocols: None, 46 - } 47 - } 48 - }
··· 34 self.version 35 } 36 }
+1 -2
crates/buttplug_server_device_config/src/device_config_file/mod.rs
··· 12 mod user; 13 14 use base::BaseConfigFile; 15 - use uuid::Uuid; 16 17 - use crate::{UserDeviceIdentifier, device_config_file::{ 18 protocol::ProtocolDefinition, 19 user::{UserConfigDefinition, UserConfigFile, UserDeviceConfigPair}, 20 }};
··· 12 mod user; 13 14 use base::BaseConfigFile; 15 16 + use crate::{device_config_file::{ 17 protocol::ProtocolDefinition, 18 user::{UserConfigDefinition, UserConfigFile, UserDeviceConfigPair}, 19 }};
-1
crates/buttplug_tests/tests/mod.rs
··· 1 - extern crate tracing; 2 #[macro_use] 3 extern crate log; 4 pub mod util;
··· 1 #[macro_use] 2 extern crate log; 3 pub mod util;
+1 -1
crates/intiface_engine/src/engine.rs
··· 99 100 // Hang out until those listeners get sick of listening. 101 info!("Intiface CLI Setup finished, running server tasks until all joined."); 102 - let mut server = setup_buttplug_server(options, &self.backdoor_server, dcm).await?; 103 let dcm = server 104 .device_manager() 105 .device_configuration_manager()
··· 99 100 // Hang out until those listeners get sick of listening. 101 info!("Intiface CLI Setup finished, running server tasks until all joined."); 102 + let server = setup_buttplug_server(options, &self.backdoor_server, dcm).await?; 103 let dcm = server 104 .device_manager() 105 .device_configuration_manager()