Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b19263d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "system/rust: Apply cargo fmt" into main

parents f27ee690 f6791115
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -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;
+2 −2
Original line number Original line Diff line number Diff line
@@ -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 });
@@ -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 });


+32 −19
Original line number Original line Diff line number Diff line
@@ -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();
@@ -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
@@ -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();
@@ -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!();
            };
            };


@@ -1126,7 +1131,8 @@ mod test {
                AttributeBackingType::Descriptor,
                AttributeBackingType::Descriptor,
                _,
                _,
                _,
                _,
            ) = data_evts.recv().await.unwrap() else {
            ) = data_evts.recv().await.unwrap()
            else {
                unreachable!();
                unreachable!();
            };
            };
        });
        });
@@ -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();
@@ -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!(
+6 −3
Original line number Original line Diff line number Diff line
@@ -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!(
@@ -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!(
@@ -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!(
+2 −6
Original line number Original line Diff line number Diff line
@@ -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 {
@@ -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