aboutsummaryrefslogtreecommitdiffstats
path: root/components/bluetooth_traits
diff options
context:
space:
mode:
authorzakorgyula <gyula.zakor@gmail.com>2016-10-07 12:42:40 +0200
committerzakorgyula <gyula.zakor@gmail.com>2016-11-04 15:36:42 +0100
commit4ed461c6e5e3349ec92c29c5a449b08b54503d90 (patch)
tree9b7862aa39ee7c58619cdfad2730497b5bee3f02 /components/bluetooth_traits
parent2b4829b89a360bfd7614f46015cb8decae78da7c (diff)
downloadservo-4ed461c6e5e3349ec92c29c5a449b08b54503d90.tar.gz
servo-4ed461c6e5e3349ec92c29c5a449b08b54503d90.zip
Accepting empty deviceName, when requesting a BluetoothDevice.
Diffstat (limited to 'components/bluetooth_traits')
-rw-r--r--components/bluetooth_traits/scanfilter.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/components/bluetooth_traits/scanfilter.rs b/components/bluetooth_traits/scanfilter.rs
index b5017de72ad..4d0da1ccb0d 100644
--- a/components/bluetooth_traits/scanfilter.rs
+++ b/components/bluetooth_traits/scanfilter.rs
@@ -25,7 +25,7 @@ impl ServiceUUIDSequence {
#[derive(Deserialize, Serialize)]
pub struct BluetoothScanfilter {
- name: String,
+ name: Option<String>,
name_prefix: String,
services: ServiceUUIDSequence,
manufacturer_id: Option<u16>,
@@ -33,7 +33,7 @@ pub struct BluetoothScanfilter {
}
impl BluetoothScanfilter {
- pub fn new(name: String,
+ pub fn new(name: Option<String>,
name_prefix: String,
services: Vec<String>,
manufacturer_id: Option<u16>,
@@ -48,8 +48,8 @@ impl BluetoothScanfilter {
}
}
- pub fn get_name(&self) -> &str {
- &self.name
+ pub fn get_name(&self) -> Option<&str> {
+ self.name.as_ref().map(|s| s.as_str())
}
pub fn get_name_prefix(&self) -> &str {
@@ -69,12 +69,12 @@ impl BluetoothScanfilter {
}
pub fn is_empty_or_invalid(&self) -> bool {
- (self.name.is_empty() &&
+ (self.name.is_none() &&
self.name_prefix.is_empty() &&
self.get_services().is_empty() &&
self.manufacturer_id.is_none() &&
self.service_data_uuid.is_empty()) ||
- self.name.len() > MAX_NAME_LENGTH ||
+ self.get_name().unwrap_or("").len() > MAX_NAME_LENGTH ||
self.name_prefix.len() > MAX_NAME_LENGTH
}
}