Skip to content

Commit 75d45d2

Browse files
committed
chore: run rustfmt
1 parent a33d925 commit 75d45d2

File tree

9 files changed

+31
-36
lines changed

9 files changed

+31
-36
lines changed

examples/lights.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,15 @@ async fn main() -> anyhow::Result<()> {
6868
// dance party
6969
let mut rng = rng();
7070
for _ in 0..20 {
71-
let color_cmd = vec![0x56, rng.random(), rng.random(), rng.random(), 0x00, 0xF0, 0xAA];
71+
let color_cmd = vec![
72+
0x56,
73+
rng.random(),
74+
rng.random(),
75+
rng.random(),
76+
0x00,
77+
0xF0,
78+
0xAA,
79+
];
7280
light
7381
.write(&cmd_char, &color_cmd, WriteType::WithoutResponse)
7482
.await?;

src/bluez/peripheral.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ impl Peripheral {
9797
}
9898

9999
fn characteristic_info(&self, characteristic: &Characteristic) -> Result<CharacteristicInfo> {
100-
let services = self.services.lock()
101-
.map_err(Into::<Error>::into)?;
100+
let services = self.services.lock().map_err(Into::<Error>::into)?;
102101
get_characteristic(
103102
&services,
104103
&characteristic.service_uuid,
@@ -109,8 +108,7 @@ impl Peripheral {
109108
}
110109

111110
fn descriptor_info(&self, descriptor: &Descriptor) -> Result<DescriptorInfo> {
112-
let services = self.services.lock()
113-
.map_err(Into::<Error>::into)?;
111+
let services = self.services.lock().map_err(Into::<Error>::into)?;
114112
let characteristic = get_characteristic(
115113
&services,
116114
&descriptor.service_uuid,
@@ -224,8 +222,7 @@ impl api::Peripheral for Peripheral {
224222
},
225223
);
226224
}
227-
*(self.services.lock()
228-
.map_err(Into::<Error>::into)?) = services_internal;
225+
*(self.services.lock().map_err(Into::<Error>::into)?) = services_internal;
229226
Ok(())
230227
}
231228

src/corebluetooth/peripheral.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl api::Peripheral for Peripheral {
213213
.properties
214214
.lock()
215215
.map_err(Into::<Error>::into)?
216-
.clone()
216+
.clone(),
217217
))
218218
}
219219

@@ -252,10 +252,7 @@ impl api::Peripheral for Peripheral {
252252
.await?;
253253
match fut.await {
254254
CoreBluetoothReply::Connected(services) => {
255-
*(self.shared
256-
.services
257-
.lock()
258-
.map_err(Into::<Error>::into)?) = services;
255+
*(self.shared.services.lock().map_err(Into::<Error>::into)?) = services;
259256
self.shared
260257
.emit_event(CentralEvent::DeviceConnected(self.shared.uuid.into()));
261258
}

src/droidplug/peripheral.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ impl api::Peripheral for Peripheral {
218218
}
219219

220220
async fn properties(&self) -> Result<Option<PeripheralProperties>> {
221-
let guard = self.shared.lock()
222-
.map_err(Into::<Error>::into)?;
221+
let guard = self.shared.lock().map_err(Into::<Error>::into)?;
223222
Ok((&guard.properties).clone())
224223
}
225224

@@ -305,8 +304,7 @@ impl api::Peripheral for Peripheral {
305304
characteristics,
306305
})
307306
}
308-
let mut guard = self.shared.lock()
309-
.map_err(Into::<Error>::into)?;
307+
let mut guard = self.shared.lock().map_err(Into::<Error>::into)?;
310308
guard.services = BTreeSet::from_iter(peripheral_services.clone());
311309
guard.characteristics = BTreeSet::from_iter(peripheral_characteristics.clone());
312310
Ok(())

src/winrtble/adapter.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ impl Central for Adapter {
8787
}
8888

8989
async fn start_scan(&self, filter: ScanFilter) -> Result<()> {
90-
let watcher = self.watcher.lock()
91-
.map_err(Into::<Error>::into)?;
90+
let watcher = self.watcher.lock().map_err(Into::<Error>::into)?;
9291
let manager = self.manager.clone();
9392
watcher.start(
9493
filter,
@@ -110,8 +109,7 @@ impl Central for Adapter {
110109
}
111110

112111
async fn stop_scan(&self) -> Result<()> {
113-
let watcher = self.watcher.lock()
114-
.map_err(Into::<Error>::into)?;
112+
let watcher = self.watcher.lock().map_err(Into::<Error>::into)?;
115113
watcher.stop()?;
116114
Ok(())
117115
}

src/winrtble/ble/characteristic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ use crate::{
1919
};
2020

2121
use log::{debug, trace};
22-
use std::{future::IntoFuture, collections::HashMap};
22+
use std::{collections::HashMap, future::IntoFuture};
2323
use uuid::Uuid;
24+
use windows::core::Ref;
2425
use windows::{
2526
Devices::Bluetooth::{
2627
BluetoothCacheMode,
@@ -32,7 +33,6 @@ use windows::{
3233
Foundation::TypedEventHandler,
3334
Storage::Streams::{DataReader, DataWriter},
3435
};
35-
use windows::core::Ref;
3636

3737
pub type NotifiyEventHandler = Box<dyn Fn(Vec<u8>) + Send>;
3838

src/winrtble/ble/device.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ impl BLEDevice {
4141
) -> Result<Self> {
4242
let async_op = BluetoothLEDevice::FromBluetoothAddressAsync(address.into())
4343
.map_err(|_| Error::DeviceNotFound)?;
44-
let device = async_op.into_future().await
44+
let device = async_op
45+
.into_future()
46+
.await
4547
.map_err(|_| Error::DeviceNotFound)?;
4648
let connection_status_handler =
4749
TypedEventHandler::new(move |sender: Ref<BluetoothLEDevice>, _| {
@@ -76,8 +78,7 @@ impl BLEDevice {
7678
.device
7779
.GetGattServicesWithCacheModeAsync(cache_mode)
7880
.map_err(winrt_error)?;
79-
let service_result = async_op.into_future().await
80-
.map_err(winrt_error)?;
81+
let service_result = async_op.into_future().await.map_err(winrt_error)?;
8182
Ok(service_result)
8283
}
8384

src/winrtble/ble/watcher.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// Copyright (c) 2014 The Rust Project Developers
1313

1414
use crate::{api::ScanFilter, Error, Result};
15-
use windows::{Devices::Bluetooth::Advertisement::*, core::Ref, Foundation::TypedEventHandler};
15+
use windows::{core::Ref, Devices::Bluetooth::Advertisement::*, Foundation::TypedEventHandler};
1616

17-
pub type AdvertisementEventHandler = Box<dyn Fn(&BluetoothLEAdvertisementReceivedEventArgs)-> windows::core::Result<()> + Send>;
17+
pub type AdvertisementEventHandler =
18+
Box<dyn Fn(&BluetoothLEAdvertisementReceivedEventArgs) -> windows::core::Result<()> + Send>;
1819

1920
#[derive(Debug)]
2021
pub struct BLEWatcher {
@@ -36,15 +37,11 @@ impl BLEWatcher {
3637

3738
pub fn start(&self, filter: ScanFilter, on_received: AdvertisementEventHandler) -> Result<()> {
3839
let ScanFilter { services } = filter;
39-
let ad = self
40-
.watcher
41-
.AdvertisementFilter()?
42-
.Advertisement()?;
40+
let ad = self.watcher.AdvertisementFilter()?.Advertisement()?;
4341
let ad_services = ad.ServiceUuids()?;
4442
ad_services.Clear()?;
4543
for service in services {
46-
ad_services
47-
.Append(windows::core::GUID::from(service.as_u128()))?;
44+
ad_services.Append(windows::core::GUID::from(service.as_u128()))?;
4845
}
4946
self.watcher
5047
.SetScanningMode(BluetoothLEScanningMode::Active)?;

src/winrtble/manager.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
use super::adapter::Adapter;
1515
use crate::{api, Result};
16-
use std::future::IntoFuture;
1716
use async_trait::async_trait;
17+
use std::future::IntoFuture;
1818
use windows::Devices::Radios::{Radio, RadioKind};
1919

2020
/// Implementation of [api::Manager](crate::api::Manager).
@@ -32,8 +32,7 @@ impl api::Manager for Manager {
3232
type Adapter = Adapter;
3333

3434
async fn adapters(&self) -> Result<Vec<Adapter>> {
35-
let radios = Radio::GetRadiosAsync()?
36-
.into_future().await?;
35+
let radios = Radio::GetRadiosAsync()?.into_future().await?;
3736
radios
3837
.into_iter()
3938
.filter(|radio| radio.Kind() == Ok(RadioKind::Bluetooth))

0 commit comments

Comments
 (0)