mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Updates Bluetooth type to use BufferSource
This commit is contained in:
parent
5bf2e71407
commit
ef0e93c9b1
4 changed files with 17 additions and 11 deletions
|
@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::Bluetoot
|
||||||
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerBinding::
|
use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerBinding::
|
||||||
BluetoothRemoteGATTServerMethods;
|
BluetoothRemoteGATTServerMethods;
|
||||||
use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, PermissionState};
|
use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, PermissionState};
|
||||||
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
|
use dom::bindings::codegen::UnionTypes::{ArrayBufferViewOrArrayBuffer, StringOrUnsignedLong};
|
||||||
use dom::bindings::error::Error::{self, Network, Security, Type};
|
use dom::bindings::error::Error::{self, Network, Security, Type};
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
use dom::bindings::refcounted::{Trusted, TrustedPromise};
|
||||||
|
@ -442,12 +442,20 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdatafilterinit-canonicalizing
|
// https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdatafilterinit-canonicalizing
|
||||||
fn canonicalize_bluetooth_data_filter_init(bdfi: &BluetoothDataFilterInit) -> Fallible<(Vec<u8>, Vec<u8>)> {
|
fn canonicalize_bluetooth_data_filter_init(bdfi: &BluetoothDataFilterInit) -> Fallible<(Vec<u8>, Vec<u8>)> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let data_prefix = bdfi.dataPrefix.clone().unwrap_or(vec![]);
|
let data_prefix = match bdfi.dataPrefix {
|
||||||
|
Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(),
|
||||||
|
Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(),
|
||||||
|
None => vec![]
|
||||||
|
};
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
// If no mask present, mask will be a sequence of 0xFF bytes the same length as dataPrefix.
|
// If no mask present, mask will be a sequence of 0xFF bytes the same length as dataPrefix.
|
||||||
// Masking dataPrefix with this, leaves dataPrefix untouched.
|
// Masking dataPrefix with this, leaves dataPrefix untouched.
|
||||||
let mask = bdfi.mask.clone().unwrap_or(vec![0xFF; data_prefix.len()]);
|
let mask = match bdfi.mask {
|
||||||
|
Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(),
|
||||||
|
Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(),
|
||||||
|
None => vec![0xFF; data_prefix.len()]
|
||||||
|
};
|
||||||
|
|
||||||
// Step 3.
|
// Step 3.
|
||||||
if mask.len() != data_prefix.len() {
|
if mask.len() != data_prefix.len() {
|
||||||
|
|
|
@ -167,8 +167,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris
|
||||||
|
|
||||||
// Step 2 - 3.
|
// Step 2 - 3.
|
||||||
let vec = match value {
|
let vec = match value {
|
||||||
ArrayBufferViewOrArrayBuffer::ArrayBufferView(mut avb) => avb.to_vec(),
|
ArrayBufferViewOrArrayBuffer::ArrayBufferView(avb) => avb.to_vec(),
|
||||||
ArrayBufferViewOrArrayBuffer::ArrayBuffer(mut ab) => ab.to_vec(),
|
ArrayBufferViewOrArrayBuffer::ArrayBuffer(ab) => ab.to_vec(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH {
|
if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH {
|
||||||
|
|
|
@ -126,8 +126,8 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
|
||||||
|
|
||||||
// Step 2 - 3.
|
// Step 2 - 3.
|
||||||
let vec = match value {
|
let vec = match value {
|
||||||
ArrayBufferViewOrArrayBuffer::ArrayBufferView(mut avb) => avb.to_vec(),
|
ArrayBufferViewOrArrayBuffer::ArrayBufferView(avb) => avb.to_vec(),
|
||||||
ArrayBufferViewOrArrayBuffer::ArrayBuffer(mut ab) => ab.to_vec(),
|
ArrayBufferViewOrArrayBuffer::ArrayBuffer(ab) => ab.to_vec(),
|
||||||
};
|
};
|
||||||
if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH {
|
if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH {
|
||||||
p.reject_error(InvalidModification);
|
p.reject_error(InvalidModification);
|
||||||
|
|
|
@ -5,10 +5,8 @@
|
||||||
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
|
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
|
||||||
|
|
||||||
dictionary BluetoothDataFilterInit {
|
dictionary BluetoothDataFilterInit {
|
||||||
// BufferSource dataPrefix;
|
BufferSource dataPrefix;
|
||||||
sequence<octet> dataPrefix;
|
BufferSource mask;
|
||||||
// BufferSource mask;
|
|
||||||
sequence<octet> mask;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary BluetoothLEScanFilterInit {
|
dictionary BluetoothLEScanFilterInit {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue