diff options
author | Attila Dusnoki <dati91@gmail.com> | 2016-11-08 13:22:33 +0100 |
---|---|---|
committer | Attila Dusnoki <dati91@gmail.com> | 2016-11-08 13:27:56 +0100 |
commit | e7e7c74c9ee1a296683e01b97336ef9bdf7f009c (patch) | |
tree | ec5c711cc61bd94f3de4c1394b97ae1174eb5d95 /components/bluetooth_traits | |
parent | 4a7ea7242935a9bea9ac82f82dd22b5ac8aad673 (diff) | |
download | servo-e7e7c74c9ee1a296683e01b97336ef9bdf7f009c.tar.gz servo-e7e7c74c9ee1a296683e01b97336ef9bdf7f009c.zip |
Webbluetooth Async behaviour
Diffstat (limited to 'components/bluetooth_traits')
-rw-r--r-- | components/bluetooth_traits/lib.rs | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/components/bluetooth_traits/lib.rs b/components/bluetooth_traits/lib.rs index d93ff4109f7..1a1dc1ec9a6 100644 --- a/components/bluetooth_traits/lib.rs +++ b/components/bluetooth_traits/lib.rs @@ -75,21 +75,43 @@ pub type BluetoothDescriptorsMsg = Vec<BluetoothDescriptorMsg>; pub type BluetoothResult<T> = Result<T, BluetoothError>; +pub type BluetoothResponseResult = Result<BluetoothResponse, BluetoothError>; + #[derive(Deserialize, Serialize)] -pub enum BluetoothMethodMsg { - RequestDevice(RequestDeviceoptions, IpcSender<BluetoothResult<BluetoothDeviceMsg>>), - GATTServerConnect(String, IpcSender<BluetoothResult<bool>>), +pub enum BluetoothRequest { + RequestDevice(RequestDeviceoptions, IpcSender<BluetoothResponseResult>), + GATTServerConnect(String, IpcSender<BluetoothResponseResult>), GATTServerDisconnect(String, IpcSender<BluetoothResult<bool>>), - GetPrimaryService(String, String, IpcSender<BluetoothResult<BluetoothServiceMsg>>), - GetPrimaryServices(String, Option<String>, IpcSender<BluetoothResult<BluetoothServicesMsg>>), - GetIncludedService(String, String, IpcSender<BluetoothResult<BluetoothServiceMsg>>), - GetIncludedServices(String, Option<String>, IpcSender<BluetoothResult<BluetoothServicesMsg>>), - GetCharacteristic(String, String, IpcSender<BluetoothResult<BluetoothCharacteristicMsg>>), - GetCharacteristics(String, Option<String>, IpcSender<BluetoothResult<BluetoothCharacteristicsMsg>>), - GetDescriptor(String, String, IpcSender<BluetoothResult<BluetoothDescriptorMsg>>), - GetDescriptors(String, Option<String>, IpcSender<BluetoothResult<BluetoothDescriptorsMsg>>), - ReadValue(String, IpcSender<BluetoothResult<Vec<u8>>>), - WriteValue(String, Vec<u8>, IpcSender<BluetoothResult<bool>>), + GetPrimaryService(String, String, IpcSender<BluetoothResponseResult>), + GetPrimaryServices(String, Option<String>, IpcSender<BluetoothResponseResult>), + GetIncludedService(String, String, IpcSender<BluetoothResponseResult>), + GetIncludedServices(String, Option<String>, IpcSender<BluetoothResponseResult>), + GetCharacteristic(String, String, IpcSender<BluetoothResponseResult>), + GetCharacteristics(String, Option<String>, IpcSender<BluetoothResponseResult>), + GetDescriptor(String, String, IpcSender<BluetoothResponseResult>), + GetDescriptors(String, Option<String>, IpcSender<BluetoothResponseResult>), + ReadValue(String, IpcSender<BluetoothResponseResult>), + WriteValue(String, Vec<u8>, IpcSender<BluetoothResponseResult>), Test(String, IpcSender<BluetoothResult<()>>), Exit, } + +#[derive(Deserialize, Serialize)] +pub enum BluetoothResponse { + RequestDevice(BluetoothDeviceMsg), + GATTServerConnect(bool), + GetPrimaryService(BluetoothServiceMsg), + GetPrimaryServices(BluetoothServicesMsg), + GetIncludedService(BluetoothServiceMsg), + GetIncludedServices(BluetoothServicesMsg), + GetCharacteristic(BluetoothCharacteristicMsg), + GetCharacteristics(BluetoothCharacteristicsMsg), + GetDescriptor(BluetoothDescriptorMsg), + GetDescriptors(BluetoothDescriptorsMsg), + ReadValue(Vec<u8>), + WriteValue(Vec<u8>), +} + +pub trait BluetoothResponseListener { + fn response(&mut self, response: BluetoothResponseResult); +} |