Loading system/rust/src/connection.rs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -190,7 +190,7 @@ impl WeakBoxRef<'_, ConnectionManager> { Ok(async move { Ok(async move { let Some((attempt, guard)) = attempt_and_guard else { let Some((attempt, guard)) = attempt_and_guard else { // if we did not make an attempt, the connection must be ready // if we did not make an attempt, the connection must be ready return Ok(LeConnection { remote_address: address }) return Ok(LeConnection { remote_address: address }); }; }; // otherwise, wait until the attempt resolves // otherwise, wait until the attempt resolves let ret = attempt.await; let ret = attempt.await; Loading system/rust/src/connection/attempt_manager.rs +2 −2 Original line number Original line Diff line number Diff line Loading @@ -92,7 +92,7 @@ impl ConnectionAttempts { let id = self.new_attempt_id(); let id = self.new_attempt_id(); let Entry::Vacant(entry) = self.attempts.entry(attempt) else { let Entry::Vacant(entry) = self.attempts.entry(attempt) else { return Err(CreateConnectionFailure::ConnectionAlreadyPending) return Err(CreateConnectionFailure::ConnectionAlreadyPending); }; }; let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel(); entry.insert(ConnectionAttemptData { conn_tx: Some(tx), id }); entry.insert(ConnectionAttemptData { conn_tx: Some(tx), id }); Loading Loading @@ -120,7 +120,7 @@ impl ConnectionAttempts { let id = self.new_attempt_id(); let id = self.new_attempt_id(); let Entry::Vacant(entry) = self.attempts.entry(attempt) else { let Entry::Vacant(entry) = self.attempts.entry(attempt) else { return Err(CreateConnectionFailure::ConnectionAlreadyPending) return Err(CreateConnectionFailure::ConnectionAlreadyPending); }; }; entry.insert(ConnectionAttemptData { conn_tx: None, id }); entry.insert(ConnectionAttemptData { conn_tx: None, id }); Loading system/rust/src/gatt/server/gatt_database.rs +32 −19 Original line number Original line Diff line number Diff line Loading @@ -818,7 +818,8 @@ mod test { CHARACTERISTIC_VALUE_HANDLE, CHARACTERISTIC_VALUE_HANDLE, AttributeBackingType::Characteristic, AttributeBackingType::Characteristic, reply, reply, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!() unreachable!() }; }; reply.send(Ok(data.clone())).unwrap(); reply.send(Ok(data.clone())).unwrap(); Loading Loading @@ -951,7 +952,8 @@ mod test { AttributeBackingType::Characteristic, AttributeBackingType::Characteristic, recv_data, recv_data, _, _, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; recv_data recv_data Loading Loading @@ -992,7 +994,9 @@ mod test { let res = tokio_test::block_on(async { let res = tokio_test::block_on(async { join!( join!( async { async { let MockDatastoreEvents::Write(_,_,_,_,reply) = data_evts.recv().await.unwrap() else { let MockDatastoreEvents::Write(_, _, _, _, reply) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; reply.send(Err(AttErrorCode::UNLIKELY_ERROR)).unwrap(); reply.send(Err(AttErrorCode::UNLIKELY_ERROR)).unwrap(); Loading Loading @@ -1073,7 +1077,8 @@ mod test { DESCRIPTOR_HANDLE, DESCRIPTOR_HANDLE, AttributeBackingType::Descriptor, AttributeBackingType::Descriptor, reply, reply, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; Loading Loading @@ -1126,7 +1131,8 @@ mod test { AttributeBackingType::Descriptor, AttributeBackingType::Descriptor, _, _, _, _, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; }); }); Loading Loading @@ -1256,7 +1262,8 @@ mod test { AttHandle(6), AttHandle(6), AttributeBackingType::Characteristic, AttributeBackingType::Characteristic, reply, reply, ) = data_evts_2.recv().await.unwrap() else { ) = data_evts_2.recv().await.unwrap() else { unreachable!() unreachable!() }; }; reply.send(Ok(data.clone())).unwrap(); reply.send(Ok(data.clone())).unwrap(); Loading Loading @@ -1511,7 +1518,13 @@ mod test { // assert: we got a callback // assert: we got a callback let event = data_evts.blocking_recv().unwrap(); let event = data_evts.blocking_recv().unwrap(); let MockRawDatastoreEvents::WriteNoResponse(TCB_IDX, CHARACTERISTIC_VALUE_HANDLE, AttributeBackingType::Characteristic, recv_data) = event else { let MockRawDatastoreEvents::WriteNoResponse( TCB_IDX, CHARACTERISTIC_VALUE_HANDLE, AttributeBackingType::Characteristic, recv_data, ) = event else { unreachable!("{event:?}"); unreachable!("{event:?}"); }; }; assert_eq!( assert_eq!( Loading system/rust/src/gatt/server/services/gatt.rs +6 −3 Original line number Original line Diff line number Diff line Loading @@ -261,7 +261,8 @@ mod test { block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); // assert: we are not registered for either indications/notifications // assert: we are not registered for either indications/notifications let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { unreachable!() unreachable!() }; }; assert_eq!( assert_eq!( Loading Loading @@ -300,7 +301,8 @@ mod test { block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); // assert: we are registered for indications // assert: we are registered for indications let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { unreachable!() unreachable!() }; }; assert_eq!( assert_eq!( Loading Loading @@ -344,7 +346,8 @@ mod test { block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); // assert: we are not registered for indications // assert: we are not registered for indications let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { unreachable!() unreachable!() }; }; assert_eq!( assert_eq!( Loading system/rust/src/gatt/server/transactions/find_by_type_value.rs +2 −6 Original line number Original line Diff line number Diff line Loading @@ -238,9 +238,7 @@ mod test { tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); // assert // assert let AttChild::AttErrorResponse(response) = response else { let AttChild::AttErrorResponse(response) = response else { unreachable!("{response:?}") }; unreachable!("{response:?}") }; assert_eq!( assert_eq!( response, response, AttErrorResponseBuilder { AttErrorResponseBuilder { Loading Loading @@ -274,9 +272,7 @@ mod test { tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); // assert: got ATTRIBUTE_NOT_FOUND erro // assert: got ATTRIBUTE_NOT_FOUND erro let AttChild::AttErrorResponse(response) = response else { let AttChild::AttErrorResponse(response) = response else { unreachable!("{response:?}") }; unreachable!("{response:?}") }; assert_eq!( assert_eq!( response, response, AttErrorResponseBuilder { AttErrorResponseBuilder { Loading Loading
system/rust/src/connection.rs +1 −1 Original line number Original line Diff line number Diff line Loading @@ -190,7 +190,7 @@ impl WeakBoxRef<'_, ConnectionManager> { Ok(async move { Ok(async move { let Some((attempt, guard)) = attempt_and_guard else { let Some((attempt, guard)) = attempt_and_guard else { // if we did not make an attempt, the connection must be ready // if we did not make an attempt, the connection must be ready return Ok(LeConnection { remote_address: address }) return Ok(LeConnection { remote_address: address }); }; }; // otherwise, wait until the attempt resolves // otherwise, wait until the attempt resolves let ret = attempt.await; let ret = attempt.await; Loading
system/rust/src/connection/attempt_manager.rs +2 −2 Original line number Original line Diff line number Diff line Loading @@ -92,7 +92,7 @@ impl ConnectionAttempts { let id = self.new_attempt_id(); let id = self.new_attempt_id(); let Entry::Vacant(entry) = self.attempts.entry(attempt) else { let Entry::Vacant(entry) = self.attempts.entry(attempt) else { return Err(CreateConnectionFailure::ConnectionAlreadyPending) return Err(CreateConnectionFailure::ConnectionAlreadyPending); }; }; let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel(); entry.insert(ConnectionAttemptData { conn_tx: Some(tx), id }); entry.insert(ConnectionAttemptData { conn_tx: Some(tx), id }); Loading Loading @@ -120,7 +120,7 @@ impl ConnectionAttempts { let id = self.new_attempt_id(); let id = self.new_attempt_id(); let Entry::Vacant(entry) = self.attempts.entry(attempt) else { let Entry::Vacant(entry) = self.attempts.entry(attempt) else { return Err(CreateConnectionFailure::ConnectionAlreadyPending) return Err(CreateConnectionFailure::ConnectionAlreadyPending); }; }; entry.insert(ConnectionAttemptData { conn_tx: None, id }); entry.insert(ConnectionAttemptData { conn_tx: None, id }); Loading
system/rust/src/gatt/server/gatt_database.rs +32 −19 Original line number Original line Diff line number Diff line Loading @@ -818,7 +818,8 @@ mod test { CHARACTERISTIC_VALUE_HANDLE, CHARACTERISTIC_VALUE_HANDLE, AttributeBackingType::Characteristic, AttributeBackingType::Characteristic, reply, reply, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!() unreachable!() }; }; reply.send(Ok(data.clone())).unwrap(); reply.send(Ok(data.clone())).unwrap(); Loading Loading @@ -951,7 +952,8 @@ mod test { AttributeBackingType::Characteristic, AttributeBackingType::Characteristic, recv_data, recv_data, _, _, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; recv_data recv_data Loading Loading @@ -992,7 +994,9 @@ mod test { let res = tokio_test::block_on(async { let res = tokio_test::block_on(async { join!( join!( async { async { let MockDatastoreEvents::Write(_,_,_,_,reply) = data_evts.recv().await.unwrap() else { let MockDatastoreEvents::Write(_, _, _, _, reply) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; reply.send(Err(AttErrorCode::UNLIKELY_ERROR)).unwrap(); reply.send(Err(AttErrorCode::UNLIKELY_ERROR)).unwrap(); Loading Loading @@ -1073,7 +1077,8 @@ mod test { DESCRIPTOR_HANDLE, DESCRIPTOR_HANDLE, AttributeBackingType::Descriptor, AttributeBackingType::Descriptor, reply, reply, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; Loading Loading @@ -1126,7 +1131,8 @@ mod test { AttributeBackingType::Descriptor, AttributeBackingType::Descriptor, _, _, _, _, ) = data_evts.recv().await.unwrap() else { ) = data_evts.recv().await.unwrap() else { unreachable!(); unreachable!(); }; }; }); }); Loading Loading @@ -1256,7 +1262,8 @@ mod test { AttHandle(6), AttHandle(6), AttributeBackingType::Characteristic, AttributeBackingType::Characteristic, reply, reply, ) = data_evts_2.recv().await.unwrap() else { ) = data_evts_2.recv().await.unwrap() else { unreachable!() unreachable!() }; }; reply.send(Ok(data.clone())).unwrap(); reply.send(Ok(data.clone())).unwrap(); Loading Loading @@ -1511,7 +1518,13 @@ mod test { // assert: we got a callback // assert: we got a callback let event = data_evts.blocking_recv().unwrap(); let event = data_evts.blocking_recv().unwrap(); let MockRawDatastoreEvents::WriteNoResponse(TCB_IDX, CHARACTERISTIC_VALUE_HANDLE, AttributeBackingType::Characteristic, recv_data) = event else { let MockRawDatastoreEvents::WriteNoResponse( TCB_IDX, CHARACTERISTIC_VALUE_HANDLE, AttributeBackingType::Characteristic, recv_data, ) = event else { unreachable!("{event:?}"); unreachable!("{event:?}"); }; }; assert_eq!( assert_eq!( Loading
system/rust/src/gatt/server/services/gatt.rs +6 −3 Original line number Original line Diff line number Diff line Loading @@ -261,7 +261,8 @@ mod test { block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); // assert: we are not registered for either indications/notifications // assert: we are not registered for either indications/notifications let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { unreachable!() unreachable!() }; }; assert_eq!( assert_eq!( Loading Loading @@ -300,7 +301,8 @@ mod test { block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); // assert: we are registered for indications // assert: we are registered for indications let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { unreachable!() unreachable!() }; }; assert_eq!( assert_eq!( Loading Loading @@ -344,7 +346,8 @@ mod test { block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap(); // assert: we are not registered for indications // assert: we are not registered for indications let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else { unreachable!() unreachable!() }; }; assert_eq!( assert_eq!( Loading
system/rust/src/gatt/server/transactions/find_by_type_value.rs +2 −6 Original line number Original line Diff line number Diff line Loading @@ -238,9 +238,7 @@ mod test { tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); // assert // assert let AttChild::AttErrorResponse(response) = response else { let AttChild::AttErrorResponse(response) = response else { unreachable!("{response:?}") }; unreachable!("{response:?}") }; assert_eq!( assert_eq!( response, response, AttErrorResponseBuilder { AttErrorResponseBuilder { Loading Loading @@ -274,9 +272,7 @@ mod test { tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db)); // assert: got ATTRIBUTE_NOT_FOUND erro // assert: got ATTRIBUTE_NOT_FOUND erro let AttChild::AttErrorResponse(response) = response else { let AttChild::AttErrorResponse(response) = response else { unreachable!("{response:?}") }; unreachable!("{response:?}") }; assert_eq!( assert_eq!( response, response, AttErrorResponseBuilder { AttErrorResponseBuilder { Loading