diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index 19e78e09f84d..1a0e9c020100 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTCharacteristicBinding:: BluetoothRemoteGATTCharacteristicMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; 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, ErrorResult}; use dom::bindings::global::GlobalRef; @@ -19,7 +18,7 @@ use dom::bindings::str::ByteString; use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties; use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor; use dom::bluetoothremotegattservice::BluetoothRemoteGATTService; -use dom::bluetoothuuid::BluetoothUUID; +use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID}; use ipc_channel::ipc::{self, IpcSender}; use net_traits::bluetooth_thread::{BluetoothMethodMsg, BluetoothObjectMsg}; use util::str::DOMString; @@ -94,7 +93,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor - fn GetDescriptor(&self, descriptor: StringOrUnsignedLong) -> Fallible> { + fn GetDescriptor(&self, descriptor: BluetoothDescriptorUUID) -> Fallible> { let uuid: String = match BluetoothUUID::GetDescriptor(self.global().r(), descriptor.clone()) { Ok(domstring) => domstring.to_string(), Err(error) => return Err(error), @@ -124,7 +123,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptors fn GetDescriptors(&self, - descriptor: Option) + descriptor: Option) -> Fallible>> { let mut uuid: Option = None; if let Some(d)= descriptor { diff --git a/components/script/dom/bluetoothremotegattserver.rs b/components/script/dom/bluetoothremotegattserver.rs index a6c6f42769fa..f34261eb54b7 100644 --- a/components/script/dom/bluetoothremotegattserver.rs +++ b/components/script/dom/bluetoothremotegattserver.rs @@ -5,7 +5,6 @@ use dom::bindings::codegen::Bindings::BluetoothDeviceBinding::BluetoothDeviceMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; -use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong; use dom::bindings::error::Error::Type; use dom::bindings::error::{Fallible, ErrorResult}; use dom::bindings::global::GlobalRef; @@ -13,7 +12,7 @@ use dom::bindings::js::{JS, MutHeap, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bluetoothdevice::BluetoothDevice; use dom::bluetoothremotegattservice::BluetoothRemoteGATTService; -use dom::bluetoothuuid::BluetoothUUID; +use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID}; use ipc_channel::ipc::{self, IpcSender}; use net_traits::bluetooth_thread::{BluetoothMethodMsg, BluetoothObjectMsg}; use std::cell::Cell; @@ -106,7 +105,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice - fn GetPrimaryService(&self, service: StringOrUnsignedLong) -> Fallible> { + fn GetPrimaryService(&self, service: BluetoothServiceUUID) -> Fallible> { let uuid: String = match BluetoothUUID::GetService(self.global().r(), service.clone()) { Ok(domstring) => domstring.to_string(), Err(error) => return Err(error), @@ -138,7 +137,7 @@ impl BluetoothRemoteGATTServerMethods for BluetoothRemoteGATTServer { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservices fn GetPrimaryServices(&self, - service: Option) + service: Option) -> Fallible>> { let mut uuid: Option = None; if let Some(s)= service { diff --git a/components/script/dom/bluetoothremotegattservice.rs b/components/script/dom/bluetoothremotegattservice.rs index 77820521552f..c8d46c29904f 100644 --- a/components/script/dom/bluetoothremotegattservice.rs +++ b/components/script/dom/bluetoothremotegattservice.rs @@ -4,7 +4,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; -use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong; use dom::bindings::error::Error::Type; use dom::bindings::error::Fallible; use dom::bindings::global::GlobalRef; @@ -13,7 +12,7 @@ use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties; use dom::bluetoothdevice::BluetoothDevice; use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic; -use dom::bluetoothuuid::BluetoothUUID; +use dom::bluetoothuuid::{BluetoothCharacteristicUUID, BluetoothUUID}; use ipc_channel::ipc::{self, IpcSender}; use net_traits::bluetooth_thread::{BluetoothMethodMsg, BluetoothObjectMsg}; use util::str::DOMString; @@ -86,7 +85,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getcharacteristic fn GetCharacteristic(&self, - characteristic: StringOrUnsignedLong) + characteristic: BluetoothCharacteristicUUID) -> Fallible> { let uuid: String = match BluetoothUUID::GetCharacteristic(self.global().r(), characteristic.clone()) { Ok(domstring) => domstring.to_string(), @@ -137,7 +136,7 @@ impl BluetoothRemoteGATTServiceMethods for BluetoothRemoteGATTService { // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattservice-getcharacteristics fn GetCharacteristics(&self, - characteristic: Option) + characteristic: Option) -> Fallible>> { let mut uuid: Option = None; if let Some(c)= characteristic { diff --git a/components/script/dom/bluetoothuuid.rs b/components/script/dom/bluetoothuuid.rs index e916c6ebded3..d4ed2b5e6a7d 100644 --- a/components/script/dom/bluetoothuuid.rs +++ b/components/script/dom/bluetoothuuid.rs @@ -11,6 +11,9 @@ use regex::Regex; use util::str::DOMString; pub type UUID = DOMString; +pub type BluetoothServiceUUID = StringOrUnsignedLong; +pub type BluetoothCharacteristicUUID = StringOrUnsignedLong; +pub type BluetoothDescriptorUUID = StringOrUnsignedLong; // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothuuid #[dom_struct] @@ -274,7 +277,7 @@ impl BluetoothUUID { } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getservice - pub fn GetService(globalref: GlobalRef, name: StringOrUnsignedLong) -> Fallible { + pub fn GetService(globalref: GlobalRef, name: BluetoothServiceUUID) -> Fallible { BluetoothUUID::resolve_uuid_name(globalref, name, BLUETOOTH_ASSIGNED_SERVICES, @@ -282,7 +285,7 @@ impl BluetoothUUID { } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getcharacteristic - pub fn GetCharacteristic(globalref: GlobalRef, name: StringOrUnsignedLong) -> Fallible { + pub fn GetCharacteristic(globalref: GlobalRef, name: BluetoothCharacteristicUUID) -> Fallible { BluetoothUUID::resolve_uuid_name(globalref, name, BLUETOOTH_ASSIGNED_CHARCTERISTICS, @@ -290,7 +293,7 @@ impl BluetoothUUID { } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothuuid-getdescriptor - pub fn GetDescriptor(globalref: GlobalRef, name: StringOrUnsignedLong) -> Fallible { + pub fn GetDescriptor(globalref: GlobalRef, name: BluetoothDescriptorUUID) -> Fallible { BluetoothUUID::resolve_uuid_name(globalref, name, BLUETOOTH_ASSIGNED_DESCRIPTORS, diff --git a/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl b/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl index 294e00e1b854..2f721203ee12 100644 --- a/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl +++ b/components/script/dom/webidls/BluetoothRemoteGATTCharacteristic.webidl @@ -11,9 +11,9 @@ interface BluetoothRemoteGATTCharacteristic { readonly attribute BluetoothCharacteristicProperties properties; readonly attribute ByteString? value; [Throws] - BluetoothRemoteGATTDescriptor getDescriptor((DOMString or unsigned long) descriptor); + BluetoothRemoteGATTDescriptor getDescriptor(BluetoothDescriptorUUID descriptor); [Throws] - sequence getDescriptors(optional (DOMString or unsigned long) descriptor); + sequence getDescriptors(optional BluetoothDescriptorUUID descriptor); //Promise getDescriptor(BluetoothDescriptorUUID descriptor); //Promise> //getDescriptors(optional BluetoothDescriptorUUID descriptor); diff --git a/components/script/dom/webidls/BluetoothRemoteGATTServer.webidl b/components/script/dom/webidls/BluetoothRemoteGATTServer.webidl index 835a6444103d..1d48a19a1730 100644 --- a/components/script/dom/webidls/BluetoothRemoteGATTServer.webidl +++ b/components/script/dom/webidls/BluetoothRemoteGATTServer.webidl @@ -13,9 +13,9 @@ interface BluetoothRemoteGATTServer { [Throws] void disconnect(); [Throws] - BluetoothRemoteGATTService getPrimaryService((DOMString or unsigned long) service); + BluetoothRemoteGATTService getPrimaryService(BluetoothServiceUUID service); [Throws] - sequence getPrimaryServices(optional (DOMString or unsigned long) service); + sequence getPrimaryServices(optional BluetoothServiceUUID service); //Promise getPrimaryService(BluetoothServiceUUID service); //Promise>getPrimaryServices(optional BluetoothServiceUUID service); //Promise connect(); diff --git a/components/script/dom/webidls/BluetoothRemoteGATTService.webidl b/components/script/dom/webidls/BluetoothRemoteGATTService.webidl index e6673f693977..3a41865de1ea 100644 --- a/components/script/dom/webidls/BluetoothRemoteGATTService.webidl +++ b/components/script/dom/webidls/BluetoothRemoteGATTService.webidl @@ -10,10 +10,10 @@ interface BluetoothRemoteGATTService { readonly attribute DOMString uuid; readonly attribute boolean isPrimary; [Throws] - BluetoothRemoteGATTCharacteristic getCharacteristic((DOMString or unsigned long) characteristic); + BluetoothRemoteGATTCharacteristic getCharacteristic(BluetoothCharacteristicUUID characteristic); [Throws] sequence getCharacteristics - (optional (DOMString or unsigned long) characteristic); + (optional BluetoothCharacteristicUUID characteristic); //PromisegetCharacteristic(BluetoothCharacteristicUUID characteristic); //Promise> //getCharacteristics(optional BluetoothCharacteristicUUID characteristic);