diff options
author | Anthony Urena <anthony.urena@protonmail.com> | 2018-03-24 10:53:48 -0400 |
---|---|---|
committer | Anthony Urena <anthony.urena@protonmail.com> | 2018-03-24 20:46:12 -0400 |
commit | 40235da2d3c6eb5b9e36f9b63b6f96698f2f64c3 (patch) | |
tree | f9352a55fb8dfd343ac24f75e2a622eae3261d88 /components/script/dom/bluetoothremotegattdescriptor.rs | |
parent | b8279b376bb4b6118c5a65fa6aeaf5a08c6e953b (diff) | |
download | servo-40235da2d3c6eb5b9e36f9b63b6f96698f2f64c3.tar.gz servo-40235da2d3c6eb5b9e36f9b63b6f96698f2f64c3.zip |
Switches WriteValue to use BufferSource
Diffstat (limited to 'components/script/dom/bluetoothremotegattdescriptor.rs')
-rw-r--r-- | components/script/dom/bluetoothremotegattdescriptor.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index 94023d6ffa0..54a6b1142b3 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -11,6 +11,7 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTDescriptorBinding::BluetoothRemoteGATTDescriptorMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerMethods; use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; +use dom::bindings::codegen::UnionTypes::ArrayBufferViewOrArrayBuffer; use dom::bindings::error::Error::{self, InvalidModification, Network, Security}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::root::{Dom, DomRoot}; @@ -114,7 +115,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { #[allow(unrooted_must_root)] // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue - fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> { + fn WriteValue(&self, value: ArrayBufferViewOrArrayBuffer) -> Rc<Promise> { let p = Promise::new(&self.global()); // Step 1. @@ -124,7 +125,11 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { } // Step 2 - 3. - if value.len() > MAXIMUM_ATTRIBUTE_LENGTH { + let v = match value { + ArrayBufferViewOrArrayBuffer::ArrayBufferView(mut avb) => avb.to_vec(), + ArrayBufferViewOrArrayBuffer::ArrayBuffer(mut ab) => ab.to_vec(), + }; + if v.len() > MAXIMUM_ATTRIBUTE_LENGTH { p.reject_error(InvalidModification); return p; } @@ -140,7 +145,7 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { // in writeValue function and in handle_response function. let sender = response_async(&p, self); self.get_bluetooth_thread().send( - BluetoothRequest::WriteValue(self.get_instance_id(), value, sender)).unwrap(); + BluetoothRequest::WriteValue(self.get_instance_id(), v, sender)).unwrap(); return p; } } |