Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Better WSDM UX #605

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions buttplug/src/server/device/configuration/specifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,37 @@ impl PartialEq for BluetoothLESpecifier {
}
}

impl PartialEq<WebsocketSpecifier> for BluetoothLESpecifier {
fn eq(&self, other: &WebsocketSpecifier) -> bool {
// If names or manufacturer data are found, use those automatically.
if self.names.intersection(&other.names).count() > 0 {
return true;
}
// Otherwise, try wildcarded names.
for name in &self.names {
for other_name in &other.names {
let compare_name: &String;
let mut wildcard: String;
if name.ends_with('*') {
wildcard = name.clone();
compare_name = other_name;
} else if other_name.ends_with('*') {
wildcard = other_name.clone();
compare_name = name;
} else {
continue;
}
// Remove asterisk from the end of the wildcard
wildcard.pop();
if compare_name.starts_with(&wildcard) {
return true;
}
}
}
false
}
}

impl BluetoothLESpecifier {
pub fn new(
names: HashSet<String>,
Expand Down Expand Up @@ -385,6 +416,7 @@ impl PartialEq for ProtocolCommunicationSpecifier {
(HID(self_spec), HID(other_spec)) => self_spec == other_spec,
(XInput(self_spec), XInput(other_spec)) => self_spec == other_spec,
(Websocket(self_spec), Websocket(other_spec)) => self_spec == other_spec,
(BluetoothLE(self_spec), Websocket(other_spec)) => self_spec == other_spec,
(LovenseConnectService(self_spec), LovenseConnectService(other_spec)) => {
self_spec == other_spec
}
Expand Down