···218218 continue;
219219 }
220220 trace!("Device added, updating map and sending to client");
221221- let info = DeviceMessageInfoV4::from(dev.1.clone());
221221+ let info = dev.1.clone();
222222 let device = self.create_client_device(&info);
223223 self.send_client_event(ButtplugClientEvent::DeviceAdded(device));
224224 }
···238238 // If we connect successfully, we get back the channel from the transport
239239 // to send outgoing messages and receieve incoming events, all serialized.
240240 Ok(()) => {
241241- let _ = async_manager::spawn(async move {
241241+ async_manager::spawn(async move {
242242 remote_connector_event_loop::<
243243 TransportType,
244244 SerializerType,
···9595 device: Arc<Hardware>,
9696 feature_index: u32,
9797 feature_id: Uuid,
9898- ) -> BoxFuture<Result<InputReadingV4, ButtplugDeviceError>> {
9898+ ) -> BoxFuture<'_, Result<InputReadingV4, ButtplugDeviceError>> {
9999 debug!("Trying to get battery reading.");
100100 // Reading the "whitelist" endpoint for this device retrieves the battery level,
101101 // which is byte 5. All other bytes of the 20-byte result are unknown.
···175175 }
176176177177 /// Disconnects the server from a client, if it is connected.
178178- pub fn disconnect(&self) -> BoxFuture<Result<(), message::ErrorV0>> {
178178+ pub fn disconnect(&self) -> BoxFuture<'_, Result<(), message::ErrorV0>> {
179179 debug!("Buttplug Server {} disconnect requested", self.server_name);
180180 let ping_timer = self.ping_timer.clone();
181181 // As long as StopScanning/StopAllDevices aren't changed across message specs, we can inject
···3131 Serializer,
3232 ser::{self, SerializeSeq},
3333};
3434-use std::{collections::HashMap, fmt::Display, ops::RangeInclusive};
3434+use std::{fmt::Display, ops::RangeInclusive};
35353636pub static DEVICE_CONFIGURATION_JSON: &str =
3737 include_str!("../../build-config/buttplug-device-config-v4.json");
···146146147147 for (protocol_name, protocol_def) in main_config.protocols().clone().unwrap_or_default() {
148148 if let Some(specifiers) = protocol_def.communication() {
149149- dcm_builder.communication_specifier(&protocol_name, &specifiers);
149149+ dcm_builder.communication_specifier(&protocol_name, specifiers);
150150 }
151151152152 let mut default = None;
···199199200200 for (protocol_name, protocol_def) in user_config.protocols().clone().unwrap_or_default() {
201201 if let Some(specifiers) = protocol_def.communication() {
202202- dcm_builder.user_communication_specifier(&protocol_name, &specifiers);
202202+ dcm_builder.user_communication_specifier(&protocol_name, specifiers);
203203 }
204204205205 // Defaults aren't valid in user config files. All we can do is create new configurations with
···227227 if let Ok(user_config) = user_device_config_pair
228228 .config()
229229 .build_from_base_definition(base_config)
230230- {
231231- if let Err(e) =
230230+ && let Err(e) =
232231 dcm_builder.user_device_definition(user_device_config_pair.identifier(), &user_config)
233232 {
234233 error!(
···236235 e, user_config
237236 )
238237 }
239239- }
240238 } else {
241239 error!(
242240 "Device identifier {:?} does not have a match base identifier that matches anything in the base config, removing from database.",
···7070 drop(req_tx);
71717272 // Wait for the reader thread to finish
7373- if let Some(jh) = guard.read_thread.take() {
7474- if jh.join().is_ok() {
7373+ if let Some(jh) = guard.read_thread.take()
7474+ && jh.join().is_ok() {
7575 info!("device read thread joined")
7676 }
7777- }
7877 } else {
7978 //error!("Failed to take lock on device");
8079 }
···159159 let command_url = format!(
160160 "{}/{}",
161161 self.http_host,
162162- std::str::from_utf8(&msg.data())
162162+ std::str::from_utf8(msg.data())
163163 .expect("We build this in the protocol then have to serialize to [u8], but it's a string.")
164164 );
165165
···184184 // If we've gotten this far, we can expect we have a serial port definition.
185185 let mut port_def = None;
186186 for specifier in specifiers {
187187- if let ProtocolCommunicationSpecifier::Serial(serial) = specifier {
188188- if port_info.port_name == *serial.port() {
187187+ if let ProtocolCommunicationSpecifier::Serial(serial) = specifier
188188+ && port_info.port_name == *serial.port() {
189189 port_def = Some(serial.clone());
190190 break;
191191 }
192192- }
193192 }
194193 let port_def = port_def.expect("We'll always have a port definition by this point");
195194···248247 .spawn(move || {
249248 serial_read_thread(read_port, reader_sender, read_token);
250249 connected_clone.store(false, Ordering::Relaxed);
251251- if event_stream_clone.receiver_count() != 0 {
252252- if let Err(err) = event_stream_clone.send(HardwareEvent::Disconnected(format!(
250250+ if event_stream_clone.receiver_count() != 0
251251+ && let Err(err) = event_stream_clone.send(HardwareEvent::Disconnected(format!(
253252 "{:?}",
254253 &port_name_clone
255254 ))) {
···258257 err
259258 );
260259 }
261261- }
262260 })
263261 .expect("Should always be able to create thread");
264262
+2-3
crates/examples/src/bin/device_control.rs
···11-use std::collections::HashMap;
2132use buttplug_client::{
43 ButtplugClient,
···5049 for (_, device) in client.devices() {
5150 println!("{} supports these outputs:", device.name());
5251 for output_type in OutputType::iter() {
5353- for (_, feature) in device.device_features() {
5252+ for feature in device.device_features().values() {
5453 if let Some(output) = feature.feature().output()
5554 && output.contains(output_type)
5655 {
···6867 //
6968 // There's a couple of ways to send this message.
7069 let devices = client.devices();
7171- let test_client_device = devices.get(&(device_index as u32)).clone().unwrap();
7070+ let test_client_device = devices.get(&(device_index as u32)).unwrap();
72717372 // We can use the convenience functions on ButtplugClientDevice to
7473 // send the message. This version sets all of the motors on a
···81818282 let repeater = ButtplugRepeater::new(
8383 options.repeater_local_port().unwrap(),
8484- &options.repeater_remote_address().as_ref().unwrap(),
8484+ options.repeater_remote_address().as_ref().unwrap(),
8585 self.stop_token.child_token(),
8686 );
8787 select! {
···106106107107 // Hang out until those listeners get sick of listening.
108108 info!("Intiface CLI Setup finished, running server tasks until all joined.");
109109- let mut server = setup_buttplug_server(options, &self.backdoor_server, &dcm).await?;
109109+ let mut server = setup_buttplug_server(options, &self.backdoor_server, dcm).await?;
110110 let dcm = server
111111 .server()
112112 .device_manager()
+7-9
crates/intiface_engine/src/remote_server.rs
···8686 let added_event = ButtplugRemoteServerEvent::DeviceAdded {
8787 index: da.1.device_index(),
8888 name: da.1.device_name().clone(),
8989- identifier: device_info.identifier().clone().into(),
8989+ identifier: device_info.identifier().clone(),
9090 display_name: device_info.display_name().clone(),
9191 };
9292 if remote_event_sender.send(added_event).is_err() {
···153153 match server_clone.parse_message(client_message.clone()).await {
154154 Ok(ret_msg) => {
155155 // Only send event if we just connected. Sucks to check it on every message but the boolean check should be quick.
156156- if !connected && server_clone.connected() {
157157- if remote_event_sender_clone.receiver_count() > 0 {
158158- if remote_event_sender_clone.send(ButtplugRemoteServerEvent::ClientConnected(server_clone.client_name().unwrap_or("Buttplug Client (No name specified)".to_owned()).clone())).is_err() {
156156+ if !connected && server_clone.connected()
157157+ && remote_event_sender_clone.receiver_count() > 0
158158+ && remote_event_sender_clone.send(ButtplugRemoteServerEvent::ClientConnected(server_clone.client_name().unwrap_or("Buttplug Client (No name specified)".to_owned()).clone())).is_err() {
159159 error!("Cannot send event to owner, dropping and assuming local server thread has exited.");
160160 }
161161- }
162162- }
163161 if connector_clone.send(ret_msg).await.is_err() {
164162 error!("Cannot send reply to server, dropping and assuming remote server thread has exited.");
165163 }
166164 },
167165 Err(err_msg) => {
168168- if connector_clone.send(err_msg.into()).await.is_err() {
166166+ if connector_clone.send(err_msg).await.is_err() {
169167 error!("Cannot send reply to server, dropping and assuming remote server thread has exited.");
170168 }
171169 }
···213211 }
214212 Some(msg) => {
215213 let connector_clone = shared_connector.clone();
216216- if connector_clone.send(msg.into()).await.is_err() {
214214+ if connector_clone.send(msg).await.is_err() {
217215 error!("Server disappeared, exiting remote server thread.");
218216 }
219217 }
···263261 }
264262 Self {
265263 event_sender,
266266- server: server,
264264+ server,
267265 disconnect_notifier: Arc::new(Notify::new()),
268266 }
269267 }