Skip to content

Commit 9dc27e6

Browse files
committed
chore: run rustfmt
1 parent 96c8a2a commit 9dc27e6

33 files changed

Lines changed: 245 additions & 219 deletions

examples/event_driven_discovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Big Sur or later.
33

44
use btleplug::api::{
5-
bleuuid::BleUuid, Central, CentralEvent, Manager as _, Peripheral, ScanFilter,
5+
Central, CentralEvent, Manager as _, Peripheral, ScanFilter, bleuuid::BleUuid,
66
};
77
use btleplug::platform::{Adapter, Manager};
88
use futures::stream::StreamExt;

examples/lights.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Big Sur or later.
33

44
use btleplug::api::{
5-
bleuuid::uuid_from_u16, Central, Manager as _, Peripheral as _, ScanFilter, WriteType,
5+
Central, Manager as _, Peripheral as _, ScanFilter, WriteType, bleuuid::uuid_from_u16,
66
};
77
use btleplug::platform::{Adapter, Manager, Peripheral};
8-
use rand::{rng, RngExt};
8+
use rand::{RngExt, rng};
99
use std::time::Duration;
1010
use uuid::Uuid;
1111

src/bluez/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::adapter::Adapter;
2-
use crate::{api, Result};
2+
use crate::{Result, api};
33
use async_trait::async_trait;
44
use bluez_async::BluetoothSession;
55

src/common/adapter_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// Copyright (c) 2014 The Rust Project Developers
1414
use crate::api::{CentralEvent, Peripheral};
1515
use crate::platform::PeripheralId;
16-
use dashmap::{mapref::one::RefMut, DashMap};
16+
use dashmap::{DashMap, mapref::one::RefMut};
1717
use futures::stream::{Stream, StreamExt};
1818
use log::trace;
1919
use std::pin::Pin;

src/corebluetooth/adapter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::internal::{
2-
run_corebluetooth_thread, CoreBluetoothEvent, CoreBluetoothMessage, CoreBluetoothReply,
3-
CoreBluetoothReplyFuture,
2+
CoreBluetoothEvent, CoreBluetoothMessage, CoreBluetoothReply, CoreBluetoothReplyFuture,
3+
run_corebluetooth_thread,
44
};
55
use super::peripheral::{Peripheral, PeripheralId};
66
use crate::api::{Central, CentralEvent, CentralState, ScanFilter};

src/corebluetooth/central_delegate.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use futures::channel::mpsc::Sender;
2222
use futures::sink::SinkExt;
2323
use log::{error, trace};
2424
use objc2::runtime::{AnyObject, ProtocolObject};
25-
use objc2::{declare_class, msg_send_id, mutability, rc::Retained, ClassType, DeclaredClass};
25+
use objc2::{ClassType, DeclaredClass, declare_class, msg_send_id, mutability, rc::Retained};
2626
use objc2_core_bluetooth::{
2727
CBAdvertisementDataLocalNameKey, CBAdvertisementDataManufacturerDataKey,
2828
CBAdvertisementDataServiceDataKey, CBAdvertisementDataServiceUUIDsKey,
29-
CBAdvertisementDataTxPowerLevelKey, CBCentralManager,
30-
CBCentralManagerDelegate, CBCharacteristic, CBDescriptor, CBManagerState, CBPeripheral,
31-
CBPeripheralDelegate, CBService, CBUUID,
29+
CBAdvertisementDataTxPowerLevelKey, CBCentralManager, CBCentralManagerDelegate,
30+
CBCharacteristic, CBDescriptor, CBManagerState, CBPeripheral, CBPeripheralDelegate, CBService,
31+
CBUUID,
3232
};
3333
use objc2_foundation::{
3434
NSArray, NSData, NSDictionary, NSError, NSNumber, NSObject, NSObjectProtocol, NSString,
@@ -936,11 +936,14 @@ fn get_descriptor_value(descriptor: &CBDescriptor) -> Vec<u8> {
936936

937937
fn peripheral_debug(peripheral: &CBPeripheral) -> String {
938938
let uuid = unsafe { peripheral.identifier() }.UUIDString();
939-
match unsafe { peripheral.name() } { Some(name) => {
940-
format!("CBPeripheral({}, {})", name, uuid)
941-
} _ => {
942-
format!("CBPeripheral({})", uuid)
943-
}}
939+
match unsafe { peripheral.name() } {
940+
Some(name) => {
941+
format!("CBPeripheral({}, {})", name, uuid)
942+
}
943+
_ => {
944+
format!("CBPeripheral({})", uuid)
945+
}
946+
}
944947
}
945948

946949
fn service_debug(service: &CBService) -> String {

src/corebluetooth/internal.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ use super::{
1717
nsuuid_to_uuid,
1818
},
1919
};
20-
use crate::api::{CharPropFlags, Characteristic, Descriptor, ScanFilter, Service, WriteType};
2120
use crate::Error;
21+
use crate::api::{CharPropFlags, Characteristic, Descriptor, ScanFilter, Service, WriteType};
2222
use futures::channel::mpsc::{self, Receiver, Sender};
2323
use futures::select;
2424
use futures::sink::SinkExt;
2525
use futures::stream::{Fuse, StreamExt};
2626
use log::{error, trace, warn};
27-
use objc2::{msg_send_id, ClassType};
27+
use objc2::{ClassType, msg_send_id};
2828
use objc2::{rc::Retained, runtime::AnyObject};
2929
use objc2_core_bluetooth::{
3030
CBCentralManager, CBCentralManagerScanOptionAllowDuplicatesKey, CBCharacteristic,
@@ -566,8 +566,7 @@ impl CoreBluetoothInternal {
566566
) {
567567
trace!(
568568
"Got manufacturer data advertisement! {}: {:?}",
569-
manufacturer_id,
570-
manufacturer_data
569+
manufacturer_id, manufacturer_data
571570
);
572571
if let Some(p) = self.peripherals.get_mut(&peripheral_uuid) {
573572
if let Err(e) = p
@@ -703,8 +702,7 @@ impl CoreBluetoothInternal {
703702
) {
704703
trace!(
705704
"Found characteristics for peripheral {} service {}:",
706-
peripheral_uuid,
707-
service_uuid
705+
peripheral_uuid, service_uuid
708706
);
709707
for id in characteristics.keys() {
710708
trace!("{}", id);
@@ -723,9 +721,7 @@ impl CoreBluetoothInternal {
723721
) {
724722
trace!(
725723
"Found descriptors for peripheral {} service {} characteristic {}:",
726-
peripheral_uuid,
727-
service_uuid,
728-
characteristic_uuid,
724+
peripheral_uuid, service_uuid, characteristic_uuid,
729725
);
730726
for id in descriptors.keys() {
731727
trace!("{}", id);
@@ -1048,16 +1044,28 @@ impl CoreBluetoothInternal {
10481044
CBCharacteristicWriteType::CBCharacteristicWriteWithoutResponse,
10491045
);
10501046
}
1051-
pending.fut.lock().unwrap().set_reply(CoreBluetoothReply::Ok);
1047+
pending
1048+
.fut
1049+
.lock()
1050+
.unwrap()
1051+
.set_reply(CoreBluetoothReply::Ok);
10521052
} else {
1053-
pending.fut.lock().unwrap().set_reply(CoreBluetoothReply::Err(
1054-
"Characteristic no longer available".into(),
1055-
));
1053+
pending
1054+
.fut
1055+
.lock()
1056+
.unwrap()
1057+
.set_reply(CoreBluetoothReply::Err(
1058+
"Characteristic no longer available".into(),
1059+
));
10561060
}
10571061
} else {
1058-
pending.fut.lock().unwrap().set_reply(CoreBluetoothReply::Err(
1059-
"Service no longer available".into(),
1060-
));
1062+
pending
1063+
.fut
1064+
.lock()
1065+
.unwrap()
1066+
.set_reply(CoreBluetoothReply::Err(
1067+
"Service no longer available".into(),
1068+
));
10611069
}
10621070
}
10631071
}
@@ -1187,11 +1195,7 @@ impl CoreBluetoothInternal {
11871195
}
11881196
}
11891197

1190-
fn read_rssi(
1191-
&mut self,
1192-
peripheral_uuid: Uuid,
1193-
fut: CoreBluetoothReplyStateShared,
1194-
) {
1198+
fn read_rssi(&mut self, peripheral_uuid: Uuid, fut: CoreBluetoothReplyStateShared) {
11951199
if let Some(peripheral) = self.peripherals.get_mut(&peripheral_uuid) {
11961200
trace!("Reading RSSI!");
11971201
unsafe {

src/corebluetooth/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// for full license information.
77

88
use super::adapter::Adapter;
9-
use crate::{api, Result};
9+
use crate::{Result, api};
1010
use async_trait::async_trait;
1111

1212
/// Implementation of [api::Manager](crate::api::Manager).

src/corebluetooth/peripheral.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ use super::internal::{
99
CoreBluetoothMessage, CoreBluetoothReply, CoreBluetoothReplyFuture, PeripheralEventInternal,
1010
};
1111
use crate::{
12+
Error, Result,
1213
api::{
1314
self, BDAddr, CentralEvent, CharPropFlags, Characteristic, Descriptor,
1415
PeripheralProperties, Service, ValueNotification, WriteType,
1516
},
1617
common::{adapter_manager::AdapterManager, util::notifications_stream_from_broadcast_receiver},
17-
Error, Result,
1818
};
1919
use async_trait::async_trait;
2020
use futures::channel::mpsc::{Receiver, SendError, Sender};
@@ -31,7 +31,7 @@ use std::{
3131
collections::{BTreeSet, HashMap},
3232
fmt::{self, Debug, Display, Formatter},
3333
pin::Pin,
34-
sync::{atomic::AtomicU16, Arc, Mutex},
34+
sync::{Arc, Mutex, atomic::AtomicU16},
3535
};
3636
use tokio::sync::broadcast;
3737
use tokio::task;
@@ -72,11 +72,14 @@ struct Shared {
7272

7373
impl Shared {
7474
fn emit_event(&self, event: CentralEvent) {
75-
match self.manager.upgrade() { Some(manager) => {
76-
manager.emit(event);
77-
} _ => {
78-
trace!("Could not emit an event. AdapterManager has been dropped");
79-
}}
75+
match self.manager.upgrade() {
76+
Some(manager) => {
77+
manager.emit(event);
78+
}
79+
_ => {
80+
trace!("Could not emit an event. AdapterManager has been dropped");
81+
}
82+
}
8083
}
8184
}
8285

src/corebluetooth/utils/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ pub fn nsuuid_to_uuid(uuid: &NSUUID) -> Uuid {
2727
uuid.UUIDString().to_string().parse().unwrap()
2828
}
2929

30-
pub unsafe fn nsstring_to_string(nsstring: *const NSString) -> Option<String> { unsafe {
31-
nsstring
32-
.as_ref()
33-
.and_then(|ns| CStr::from_ptr(ns.UTF8String()).to_str().ok())
34-
.map(String::from)
35-
}}
30+
pub unsafe fn nsstring_to_string(nsstring: *const NSString) -> Option<String> {
31+
unsafe {
32+
nsstring
33+
.as_ref()
34+
.and_then(|ns| CStr::from_ptr(ns.UTF8String()).to_str().ok())
35+
.map(String::from)
36+
}
37+
}

0 commit comments

Comments
 (0)