mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Auto merge of #11580 - szeged:allowedservices, r=jdm
Allowed services support <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because there are no webbluetooth test api implementation yet. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11580) <!-- Reviewable:end -->
This commit is contained in:
commit
939da24cc8
2 changed files with 41 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::slice::Iter;
|
||||
|
||||
// A device name can never be longer than 29 bytes. An adv packet is at most
|
||||
|
@ -16,6 +17,14 @@ impl ServiceUUIDSequence {
|
|||
pub fn new(vec: Vec<String>) -> ServiceUUIDSequence {
|
||||
ServiceUUIDSequence(vec)
|
||||
}
|
||||
|
||||
fn get_services_set(&self) -> HashSet<String> {
|
||||
let mut set = HashSet::new();
|
||||
for s in self.0.iter() {
|
||||
set.insert(s.clone());
|
||||
}
|
||||
set
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
@ -69,6 +78,14 @@ impl BluetoothScanfilterSequence {
|
|||
pub fn iter(&self) -> Iter<BluetoothScanfilter> {
|
||||
self.0.iter()
|
||||
}
|
||||
|
||||
fn get_services_set(&self) -> HashSet<String> {
|
||||
let mut set = HashSet::new();
|
||||
for filter in self.iter() {
|
||||
set = &set | &filter.services.get_services_set();
|
||||
}
|
||||
set
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
@ -90,4 +107,8 @@ impl RequestDeviceoptions {
|
|||
pub fn get_filters(&self) -> &BluetoothScanfilterSequence {
|
||||
&self.filters
|
||||
}
|
||||
|
||||
pub fn get_services_set(&self) -> HashSet<String> {
|
||||
&self.filters.get_services_set() | &self.optional_services.get_services_set()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue