Skip to content

Commit cb86ea1

Browse files
committed
chore: Run rustfmt
1 parent 48e50a7 commit cb86ea1

File tree

8 files changed

+43
-29
lines changed

8 files changed

+43
-29
lines changed

src/bin/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct IntifaceCLIArguments {
4949
#[argh(option)]
5050
#[getset(get = "pub")]
5151
websocket_client_address: Option<String>,
52-
52+
5353
// Options that set up communications with intiface GUI
5454
/// if passed, output json for parent process via websockets
5555
#[argh(option)]
@@ -146,7 +146,6 @@ pub struct IntifaceCLIArguments {
146146
#[getset(get = "pub")]
147147
mdns_suffix: Option<String>,
148148

149-
150149
#[cfg(debug_assertions)]
151150
/// crash the main thread (that holds the runtime)
152151
#[argh(switch)]

src/device_communication_managers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ pub fn setup_server_device_comm_managers(
1717
if args.use_bluetooth_le() {
1818
info!("Including Bluetooth LE (btleplug) Device Comm Manager Support");
1919
let mut command_manager_builder = BtlePlugCommunicationManagerBuilder::default();
20-
#[cfg(target_os="ios")]
20+
#[cfg(target_os = "ios")]
2121
command_manager_builder.requires_keepalive(true);
22-
#[cfg(not(target_os="ios"))]
22+
#[cfg(not(target_os = "ios"))]
2323
command_manager_builder.requires_keepalive(false);
2424
server_builder.comm_manager(command_manager_builder);
2525
}
@@ -30,10 +30,10 @@ pub fn setup_server_device_comm_managers(
3030
#[cfg(not(any(target_os = "android", target_os = "ios")))]
3131
{
3232
use buttplug::server::device::hardware::communication::{
33+
hid::HidCommunicationManagerBuilder,
3334
lovense_dongle::{
3435
LovenseHIDDongleCommunicationManagerBuilder, LovenseSerialDongleCommunicationManagerBuilder,
3536
},
36-
hid::HidCommunicationManagerBuilder,
3737
serialport::SerialPortCommunicationManagerBuilder,
3838
};
3939
if args.use_lovense_dongle_hid() {

src/engine.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@ use crate::{
88
},
99
logging::setup_frontend_logging,
1010
options::EngineOptions,
11-
IntifaceError,
12-
ButtplugRemoteServer,
13-
ButtplugServerConnectorError
11+
ButtplugRemoteServer, ButtplugServerConnectorError, IntifaceError,
1412
};
1513
use buttplug::{
1614
core::{
1715
connector::{
18-
ButtplugRemoteServerConnector,
19-
ButtplugWebsocketClientTransport,
16+
ButtplugRemoteServerConnector, ButtplugWebsocketClientTransport,
2017
ButtplugWebsocketServerTransportBuilder,
2118
},
2219
message::serializer::ButtplugServerJSONSerializer,
2320
},
24-
server::{ButtplugServerBuilder},
21+
server::ButtplugServerBuilder,
2522
};
2623
use once_cell::sync::OnceCell;
2724
use std::{str::FromStr, sync::Arc, time::Duration};
@@ -113,7 +110,7 @@ async fn run_server(
113110
_,
114111
ButtplugServerJSONSerializer,
115112
>::new(
116-
ButtplugWebsocketClientTransport::new_insecure_connector(&addr)
113+
ButtplugWebsocketClientTransport::new_insecure_connector(&addr),
117114
))
118115
.await
119116
} else {
@@ -136,7 +133,7 @@ impl IntifaceEngine {
136133
&self,
137134
options: &EngineOptions,
138135
external_frontend: Option<Arc<dyn Frontend>>,
139-
skip_logging_setup: bool
136+
skip_logging_setup: bool,
140137
) -> Result<(), IntifaceEngineError> {
141138
// At this point we will have received and validated options.
142139

@@ -205,7 +202,13 @@ impl IntifaceEngine {
205202
let stop_child_token = self.stop_token.child_token();
206203
let options_clone = options.clone();
207204
tokio::spawn(async move {
208-
frontend_server_event_loop(&options_clone, event_receiver, frontend_clone, stop_child_token).await;
205+
frontend_server_event_loop(
206+
&options_clone,
207+
event_receiver,
208+
frontend_clone,
209+
stop_child_token,
210+
)
211+
.await;
209212
});
210213

211214
loop {

src/frontend/mod.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
pub mod process_messages;
22
mod websocket_frontend;
3+
use crate::remote_server::ButtplugRemoteServerEvent;
34
use crate::{error::IntifaceError, options::EngineOptions};
45
use async_trait::async_trait;
5-
use crate::remote_server::ButtplugRemoteServerEvent;
66
use futures::{pin_mut, Stream, StreamExt};
7+
use mdns_sd::{ServiceDaemon, ServiceInfo};
78
pub use process_messages::{EngineMessage, IntifaceMessage};
9+
use rand::distributions::{Alphanumeric, DistString};
10+
use std::collections::HashMap;
811
use std::sync::Arc;
912
use tokio::{
1013
select,
1114
sync::{broadcast, Notify},
1215
};
1316
use tokio_util::sync::CancellationToken;
1417
use websocket_frontend::WebsocketFrontend;
15-
use mdns_sd::{ServiceDaemon, ServiceInfo};
16-
use std::collections::HashMap;
17-
use rand::distributions::{Alphanumeric, DistString};
1818

1919
const VERSION: &str = env!("CARGO_PKG_VERSION");
2020

@@ -75,25 +75,37 @@ pub async fn frontend_server_event_loop(
7575
let mut mdns = None;
7676

7777
if options.broadcast_server_mdns() {
78-
// Create a daemon
78+
// Create a daemon
7979
let mdns_daemon = ServiceDaemon::new().expect("Failed to create daemon");
8080

8181
// Create a service info.
8282
let service_type = "_intiface_engine._tcp.local.";
8383
let random_suffix = Alphanumeric.sample_string(&mut rand::thread_rng(), 6);
84-
let instance_name = format!("intiface_engine_{}_{}", options.mdns_suffix().as_ref().unwrap_or(&"".to_owned()).to_owned(), random_suffix);
85-
info!("Bringing up mDNS Advertisment using instance name {}", instance_name);
84+
let instance_name = format!(
85+
"intiface_engine_{}_{}",
86+
options
87+
.mdns_suffix()
88+
.as_ref()
89+
.unwrap_or(&"".to_owned())
90+
.to_owned(),
91+
random_suffix
92+
);
93+
info!(
94+
"Bringing up mDNS Advertisment using instance name {}",
95+
instance_name
96+
);
8697
let host_name = format!("{}.local.", instance_name);
8798
let port = options.websocket_port().unwrap_or(12345);
88-
let properties:HashMap<String, String> = HashMap::new();
99+
let properties: HashMap<String, String> = HashMap::new();
89100
let mut my_service = ServiceInfo::new(
90101
service_type,
91102
&instance_name,
92103
&host_name,
93104
"",
94105
port,
95-
properties
96-
).unwrap();
106+
properties,
107+
)
108+
.unwrap();
97109
my_service = my_service.enable_addr_auto();
98110
mdns_daemon.register(my_service).unwrap();
99111
mdns = Some(mdns_daemon);

src/frontend/process_messages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use buttplug::{util::device_configuration::UserConfigDeviceIdentifier};
1+
use buttplug::util::device_configuration::UserConfigDeviceIdentifier;
22
use serde::{Deserialize, Serialize};
33

44
// Everything in this struct is an object, even if it has null contents. This is to make other

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ pub use error::*;
1414
pub use frontend::{EngineMessage, Frontend, IntifaceMessage};
1515
pub use logging::{setup_console_logging, setup_frontend_logging, BroadcastWriter};
1616
pub use options::{EngineOptions, EngineOptionsBuilder, EngineOptionsExternal};
17-
pub use remote_server::{ButtplugRemoteServer, ButtplugServerConnectorError};
17+
pub use remote_server::{ButtplugRemoteServer, ButtplugServerConnectorError};

src/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub struct EngineOptionsExternal {
8484
pub crash_main_thread: bool,
8585
pub crash_task_thread: bool,
8686
pub broadcast_server_mdns: bool,
87-
pub mdns_suffix: Option<String>
87+
pub mdns_suffix: Option<String>,
8888
}
8989

9090
impl From<EngineOptionsExternal> for EngineOptions {
@@ -115,7 +115,7 @@ impl From<EngineOptionsExternal> for EngineOptions {
115115
crash_main_thread: other.crash_main_thread,
116116
crash_task_thread: other.crash_task_thread,
117117
broadcast_server_mdns: other.broadcast_server_mdns,
118-
mdns_suffix: other.mdns_suffix
118+
mdns_suffix: other.mdns_suffix,
119119
}
120120
}
121121
}

src/remote_server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async fn run_device_event_stream(
6565
) {
6666
let server_receiver = server.event_stream();
6767
pin_mut!(server_receiver);
68-
loop {
68+
loop {
6969
match server_receiver.next().await {
7070
None => {
7171
info!("Server disconnected via server disappearance, exiting loop.");

0 commit comments

Comments
 (0)