Skip to content

Commit 15ddddc

Browse files
committed
chore: run rustfmt
1 parent 85b0646 commit 15ddddc

File tree

34 files changed

+294
-142
lines changed

34 files changed

+294
-142
lines changed

crates/buttplug_client/src/device/device.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@
1010
use crate::device::{ClientDeviceCommandValue, ClientDeviceOutputCommand};
1111

1212
use crate::{
13-
ButtplugClientMessageSender, ButtplugClientResultFuture, create_boxed_future_client_error,
13+
ButtplugClientMessageSender,
14+
ButtplugClientResultFuture,
15+
create_boxed_future_client_error,
1416
device::ClientDeviceFeature,
1517
};
1618
use buttplug_core::message::InputType;
1719
use buttplug_core::{
1820
errors::ButtplugDeviceError,
1921
message::{
20-
ButtplugServerMessageV4, DeviceFeature, DeviceMessageInfoV4, OutputType, StopDeviceCmdV4,
22+
ButtplugServerMessageV4,
23+
DeviceFeature,
24+
DeviceMessageInfoV4,
25+
OutputType,
26+
StopDeviceCmdV4,
2127
},
2228
util::stream::convert_broadcast_receiver_to_stream,
2329
};
@@ -340,7 +346,8 @@ impl ButtplugClientDevice {
340346
}
341347
}
342348

343-
impl Eq for ButtplugClientDevice {}
349+
impl Eq for ButtplugClientDevice {
350+
}
344351

345352
impl PartialEq for ButtplugClientDevice {
346353
fn eq(&self, other: &Self) -> bool {

crates/buttplug_client/src/device/feature.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@ use getset::{CopyGetters, Getters};
44
use buttplug_core::{
55
errors::{ButtplugDeviceError, ButtplugError, ButtplugMessageError},
66
message::{
7-
ButtplugDeviceMessageNameV4, ButtplugServerMessageV4, DeviceFeature, DeviceFeatureOutputLimits,
8-
InputCmdV4, InputCommandType, InputType, InputTypeReading, OutputCmdV4, OutputCommand,
9-
OutputPositionWithDuration, OutputType, OutputValue,
7+
ButtplugDeviceMessageNameV4,
8+
ButtplugServerMessageV4,
9+
DeviceFeature,
10+
DeviceFeatureOutputLimits,
11+
InputCmdV4,
12+
InputCommandType,
13+
InputType,
14+
InputTypeReading,
15+
OutputCmdV4,
16+
OutputCommand,
17+
OutputPositionWithDuration,
18+
OutputType,
19+
OutputValue,
1020
},
1121
};
1222

1323
use super::ClientDeviceOutputCommand;
1424

1525
use crate::{
16-
ButtplugClientError, ButtplugClientMessageSender, ButtplugClientResultFuture,
17-
create_boxed_future_client_error, device::ClientDeviceCommandValue,
26+
ButtplugClientError,
27+
ButtplugClientMessageSender,
28+
ButtplugClientResultFuture,
29+
create_boxed_future_client_error,
30+
device::ClientDeviceCommandValue,
1831
};
1932

2033
#[derive(Getters, CopyGetters, Clone)]
@@ -203,9 +216,7 @@ impl ClientDeviceFeature {
203216
pub fn subscribe_sensor(&self, sensor_type: InputType) -> ButtplugClientResultFuture {
204217
if let Some(sensor_map) = self.feature.input()
205218
&& let Some(sensor) = sensor_map.get(sensor_type)
206-
&& sensor
207-
.command()
208-
.contains(&InputCommandType::Subscribe)
219+
&& sensor.command().contains(&InputCommandType::Subscribe)
209220
{
210221
let msg = InputCmdV4::new(
211222
self.device_index,
@@ -225,9 +236,7 @@ impl ClientDeviceFeature {
225236
pub fn unsubscribe_sensor(&self, sensor_type: InputType) -> ButtplugClientResultFuture {
226237
if let Some(sensor_map) = self.feature.input()
227238
&& let Some(sensor) = sensor_map.get(sensor_type)
228-
&& sensor
229-
.command()
230-
.contains(&InputCommandType::Subscribe)
239+
&& sensor.command().contains(&InputCommandType::Subscribe)
231240
{
232241
let msg = InputCmdV4::new(
233242
self.device_index,

crates/buttplug_client/src/serializer/mod.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,24 @@ impl ButtplugClientJSONSerializerImpl {
4343

4444
pub fn serialize<T>(&self, msg: &[T]) -> ButtplugSerializedMessage
4545
where
46-
T: ButtplugMessage + Serialize + Deserialize<'static>+ Debug,
46+
T: ButtplugMessage + Serialize + Deserialize<'static> + Debug,
4747
{
4848
ButtplugSerializedMessage::Text(match vec_to_protocol_json(&self.validator, msg) {
49-
Ok(m) => m,
49+
Ok(m) => m,
50+
Err(e) => match vec_to_protocol_json(&self.validator, &vec![e]) {
51+
Ok(e) => {
52+
error!("Error serializing message: {:?}", e);
53+
e
54+
}
5055
Err(e) => {
51-
match vec_to_protocol_json(&self.validator, &vec![e]) {
52-
Ok(e) => {
53-
error!("Error serializing message: {:?}", e);
54-
e
55-
}
56-
Err(e) => {
57-
error!("SERIALIZER AND/OR MESSAGE SCHEMA SEEMS COMPLETELY BROKEN, SENDING BACK NULL. ERROR: {:?}", e);
58-
String::new()
59-
}
60-
}
56+
error!(
57+
"SERIALIZER AND/OR MESSAGE SCHEMA SEEMS COMPLETELY BROKEN, SENDING BACK NULL. ERROR: {:?}",
58+
e
59+
);
60+
String::new()
6161
}
62-
})
62+
},
63+
})
6364
}
6465
}
6566

crates/buttplug_core/src/message/serializer/json_serializer.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
// for full license information.
77

88
use super::ButtplugSerializerError;
9-
use crate::{errors::{ButtplugError, ButtplugMessageError}, message::{ButtplugMessage, ButtplugMessageFinalizer, ErrorV0}};
9+
use crate::{
10+
errors::{ButtplugError, ButtplugMessageError},
11+
message::{ButtplugMessage, ButtplugMessageFinalizer, ErrorV0},
12+
};
1013
use jsonschema::Validator;
1114
use serde::{Deserialize, Serialize};
1215
use serde_json::{Deserializer, Value};
@@ -34,11 +37,13 @@ where
3437
T: ButtplugMessage + Serialize + Deserialize<'static> + Debug,
3538
{
3639
let return_error_msg = |e: &dyn Display| {
37-
let err = ButtplugMessageError::MessageSerializationError(ButtplugSerializerError::JsonSerializerError(e.to_string()));
40+
let err = ButtplugMessageError::MessageSerializationError(
41+
ButtplugSerializerError::JsonSerializerError(e.to_string()),
42+
);
3843
// Just return the error message. For the server, we'll need to wrap it. For the client, we'll just die.
3944
ErrorV0::from(ButtplugError::from(err))
4045
};
41-
let val = serde_json::to_value(msg).map_err(|e| return_error_msg(&e))?;
46+
let val = serde_json::to_value(msg).map_err(|e| return_error_msg(&e))?;
4247
validator.validate(&val).map_err(|e| return_error_msg(&e))?;
4348
serde_json::to_string(&val).map_err(|e| return_error_msg(&e))
4449
}

crates/buttplug_core/src/message/v4/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ pub use {
2020
device_list::DeviceListV4,
2121
device_message_info::DeviceMessageInfoV4,
2222
input_cmd::{InputCmdV4, InputCommandType},
23-
input_reading::{InputValue, InputReadingV4, InputTypeReading},
23+
input_reading::{InputReadingV4, InputTypeReading, InputValue},
2424
output_cmd::{OutputCmdV4, OutputCommand, OutputPositionWithDuration, OutputValue},
2525
request_server_info::RequestServerInfoV4,
2626
server_info::ServerInfoV4,
2727
spec_enums::{ButtplugClientMessageV4, ButtplugDeviceMessageNameV4, ButtplugServerMessageV4},
2828
stop_all_devices::StopAllDevicesV4,
29-
stop_device_cmd::StopDeviceCmdV4
29+
stop_device_cmd::StopDeviceCmdV4,
3030
};

crates/buttplug_core/src/message/v4/output_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl OutputCommand {
7474
| OutputCommand::Position(x)
7575
| OutputCommand::Rotate(x)
7676
| OutputCommand::Vibrate(x) => x.value() as i32,
77-
| OutputCommand::PositionWithDuration(x) => x.value() as i32,
77+
OutputCommand::PositionWithDuration(x) => x.value() as i32,
7878
}
7979
}
8080

crates/buttplug_core/src/message/v4/stop_all_devices.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,23 @@ use crate::message::{
1111
ButtplugMessageFinalizer,
1212
ButtplugMessageValidator,
1313
};
14-
use serde::{Deserialize, Serialize};
1514
use getset::CopyGetters;
15+
use serde::{Deserialize, Serialize};
1616

17-
fn mk_true() -> bool { true }
17+
fn mk_true() -> bool {
18+
true
19+
}
1820

1921
#[derive(
20-
Debug, ButtplugMessage, ButtplugMessageFinalizer, PartialEq, Eq, Clone, Serialize, Deserialize, CopyGetters
22+
Debug,
23+
ButtplugMessage,
24+
ButtplugMessageFinalizer,
25+
PartialEq,
26+
Eq,
27+
Clone,
28+
Serialize,
29+
Deserialize,
30+
CopyGetters,
2131
)]
2232
#[serde(rename_all = "PascalCase")]
2333
pub struct StopAllDevicesV4 {
@@ -32,7 +42,11 @@ pub struct StopAllDevicesV4 {
3242

3343
impl Default for StopAllDevicesV4 {
3444
fn default() -> Self {
35-
Self { id: 1, inputs: true, outputs: true }
45+
Self {
46+
id: 1,
47+
inputs: true,
48+
outputs: true,
49+
}
3650
}
3751
}
3852

crates/buttplug_core/src/message/v4/stop_device_cmd.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use crate::message::{
1515
use getset::CopyGetters;
1616
use serde::{Deserialize, Serialize};
1717

18-
fn mk_true() -> bool { true }
18+
fn mk_true() -> bool {
19+
true
20+
}
1921

2022
#[derive(
2123
Debug,
@@ -26,7 +28,7 @@ fn mk_true() -> bool { true }
2628
Clone,
2729
Serialize,
2830
Deserialize,
29-
CopyGetters
31+
CopyGetters,
3032
)]
3133
#[serde(rename_all = "PascalCase")]
3234
pub struct StopDeviceCmdV4 {
@@ -46,7 +48,7 @@ impl StopDeviceCmdV4 {
4648
id: 1,
4749
device_index,
4850
inputs,
49-
outputs
51+
outputs,
5052
}
5153
}
5254
}

crates/buttplug_server/src/device/protocol.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
use buttplug_core::{
1111
errors::ButtplugDeviceError,
12-
message::{InputValue, InputReadingV4, InputType, OutputCommand},
12+
message::{InputReadingV4, InputType, InputValue, OutputCommand},
1313
};
1414
use buttplug_server_device_config::{
1515
Endpoint,
@@ -413,10 +413,8 @@ pub trait ProtocolHandler: Sync + Send {
413413

414414
// Used for clients that have inputs which can be subscribed. Subscribed inputs should be
415415
// disconnected between client sessions, but unlike keepalives are not needed to keep the
416-
// system up.
417-
fn handle_client_disconnect_cmd(
418-
&self,
419-
) -> BoxFuture<'_, Result<(), ButtplugDeviceError>> {
416+
// system up.
417+
fn handle_client_disconnect_cmd(&self) -> BoxFuture<'_, Result<(), ButtplugDeviceError>> {
420418
future::ready(Ok(())).boxed()
421419
}
422420

crates/buttplug_server/src/device/protocol_impl/galaku.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use futures_util::future::BoxFuture;
1414
use futures_util::{FutureExt, future};
1515

1616
use buttplug_core::errors::ButtplugDeviceError;
17-
use buttplug_core::message::{InputValue, InputReadingV4, InputType, InputTypeReading};
17+
use buttplug_core::message::{InputReadingV4, InputType, InputTypeReading, InputValue};
1818
use buttplug_server_device_config::Endpoint;
1919

2020
use buttplug_server_device_config::{

0 commit comments

Comments
 (0)