mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Style fix
This commit is contained in:
parent
27ad1437a1
commit
f47f8d1a5c
7 changed files with 220 additions and 200 deletions
|
@ -11,7 +11,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot
|
|||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods;
|
||||
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
|
||||
use dom::bindings::error::Error::{Network, Type};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::error::{Fallible, ErrorResult};
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{JS, MutHeap, Root};
|
||||
use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
|
||||
|
@ -61,8 +61,8 @@ impl BluetoothRemoteGATTCharacteristic {
|
|||
uuid,
|
||||
properties,
|
||||
instanceID),
|
||||
global,
|
||||
BluetoothRemoteGATTCharacteristicBinding::Wrap)
|
||||
global,
|
||||
BluetoothRemoteGATTCharacteristicBinding::Wrap)
|
||||
}
|
||||
|
||||
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
|
||||
|
@ -94,9 +94,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor
|
||||
fn GetDescriptor(&self,
|
||||
descriptor: StringOrUnsignedLong)
|
||||
-> Fallible<Root<BluetoothRemoteGATTDescriptor>> {
|
||||
fn GetDescriptor(&self, descriptor: StringOrUnsignedLong) -> Fallible<Root<BluetoothRemoteGATTDescriptor>> {
|
||||
let uuid: String = match BluetoothUUID::GetDescriptor(self.global().r(), descriptor.clone()) {
|
||||
Ok(domstring) => domstring.to_string(),
|
||||
Err(error) => return Err(error),
|
||||
|
@ -117,7 +115,9 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
},
|
||||
BluetoothObjectMsg::Error {
|
||||
error
|
||||
} => Err(Type(error)),
|
||||
} => {
|
||||
Err(Type(error))
|
||||
},
|
||||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
|
@ -126,12 +126,12 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
fn GetDescriptors(&self,
|
||||
descriptor: Option<StringOrUnsignedLong>)
|
||||
-> Fallible<Vec<Root<BluetoothRemoteGATTDescriptor>>> {
|
||||
let uuid: Option<String> = match descriptor {
|
||||
Some(d) => match BluetoothUUID::GetDescriptor(self.global().r(), d.clone()) {
|
||||
Ok(domstring) => Some(domstring.to_string()),
|
||||
let mut uuid: Option<String> = None;
|
||||
if let Some(d)= descriptor {
|
||||
match BluetoothUUID::GetCharacteristic(self.global().r(), d.clone()) {
|
||||
Ok(domstring) => uuid = Some(domstring.to_string()),
|
||||
Err(error) => return Err(error),
|
||||
},
|
||||
None => None,
|
||||
}
|
||||
};
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let mut descriptors: Vec<Root<BluetoothRemoteGATTDescriptor>> = vec!();
|
||||
|
@ -151,7 +151,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
descriptors.push(BluetoothRemoteGATTDescriptor::new(self.global().r(),
|
||||
&self,
|
||||
DOMString::from(uuid),
|
||||
instance_id))
|
||||
instance_id));
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -160,7 +160,9 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
},
|
||||
BluetoothObjectMsg::Error {
|
||||
error
|
||||
} => Err(Type(error)),
|
||||
} => {
|
||||
Err(Type(error))
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
@ -175,8 +177,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
if !self.Service().Device().Gatt().Connected() {
|
||||
Err(Network)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::ReadValue(self.get_instance_id(), sender)).unwrap();
|
||||
let result = receiver.recv().unwrap();
|
||||
|
@ -188,7 +189,9 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
},
|
||||
BluetoothObjectMsg::Error {
|
||||
error
|
||||
} => return Err(Type(error)),
|
||||
} => {
|
||||
return Err(Type(error))
|
||||
},
|
||||
_ => unreachable!()
|
||||
};
|
||||
*self.value.borrow_mut() = value;
|
||||
|
@ -197,7 +200,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
}
|
||||
|
||||
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue
|
||||
fn WriteValue(&self, value: Vec<u8>) -> Fallible<()> {
|
||||
fn WriteValue(&self, value: Vec<u8>) -> ErrorResult {
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
self.get_bluetooth_thread().send(
|
||||
BluetoothMethodMsg::WriteValue(self.get_instance_id(), value, sender)).unwrap();
|
||||
|
@ -206,7 +209,9 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
|||
BluetoothObjectMsg::BluetoothWriteValue => Ok(()),
|
||||
BluetoothObjectMsg::Error {
|
||||
error
|
||||
} => Err(Type(error)),
|
||||
} => {
|
||||
Err(Type(error))
|
||||
},
|
||||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue