Skip to content

Conversation

@Mettwasser
Copy link
Member

@Mettwasser Mettwasser commented Jul 6, 2025

What did you fix?

Listeners could not be run in task, especially the "call_on_update" ones.

They would yield an error such as "AsyncFnMut is not general enough".
This fixes that issue.


Reproduction steps

tokio::spawn(
    async move {
        wf_client
            .call_on_update::<Cetus, _>(
                async move |_before: &Cetus, after: &Cetus| {
                    if cetus.state == CetusState::Night {}
                },
            )
            .await.unwrap();
    }
);

Evidence/screenshot/link to line

Considerations

  • Does this contain a new dependency? [No]
  • Does this introduce opinionated data formatting or manual data entry? [No]
  • Does this pr include updated data files in a separate commit that can be reverted for a clean code-only pr? [Yes]
  • Have I run the linter? [Yes]
  • Is is a bug fix, feature request, or enhancement? [Bug Fix]

Summary by CodeRabbit

  • Refactor
    • Enhanced callback handling in asynchronous update listeners for improved flexibility.

No user-facing features or bug fixes were introduced in this release.

@Mettwasser Mettwasser requested a review from TobiTenno July 6, 2025 15:51
@coderabbitai
Copy link

coderabbitai bot commented Jul 6, 2025

## Walkthrough

The changes update the lifetime quantifiers in the trait bounds for callback parameters in three asynchronous listener methods within the `Client` implementation. The callbacks now accept two references with independent lifetimes instead of a single shared lifetime. Additionally, the `warframe-macros` crate version was updated from "6.2.0" to "7.0.0" in its `Cargo.toml`, and an extra space was removed in the dependency declaration in the main `Cargo.toml`.

## Changes

| File(s)                       | Change Summary                                                                                         |
|------------------------------|------------------------------------------------------------------------------------------------------|
| Cargo.toml, warframe-macros/Cargo.toml | Removed extra space before comma in `warframe-macros` dependency; updated `warframe-macros` version from "6.2.0" to "7.0.0". |
| src/worldstate/client.rs      | Updated callback trait bounds in three async listener methods to use two independent lifetimes instead of one shared lifetime. No logic or control flow changes. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Caller
    participant Client
    participant Callback

    Caller->>Client: call_on_update(callback)
    Client->>Callback: Invoke callback(&'a T, &'b T) with independent lifetimes
    Callback-->>Client: Complete
    Client-->>Caller: Result<(), Error>

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 66253b8b1f8670540d4341375d5d8c0a54e435b8 and a6a28246f55cf644c5e50bb74f427aaedcba50c2.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `Cargo.toml` (1 hunks)
* `warframe-macros/Cargo.toml` (1 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (1)</summary>

* warframe-macros/Cargo.toml

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* Cargo.toml

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (1)</summary>

* GitHub Check: Build

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAM3gADy4vJBpyCmQGTEgMfAB3P2wseCxcNEQAa0QAGmj7bAFmdRp6OUhsREpIAFkSXFw88s6+cus7DEcBLoAmAFZq9Fpaf0RO5GykBw882EoPFMQ0yhqeZ3EGb2cveVxYfE72xBKiMN2YrJ8AfXwMT+xuWjUEh1Ni3RQLJjeei5UJTSAkBKiPBRPLqBBYcqyDAMWAUH74DphcpVDQwN68QSRZiQZiYeCxEJRUbZSh4vhsVZoUj2MriDAvaIAQUQWIYADEMN08ChkDDIKR0mhfGQCURYBo6nBUPEEn5pPgvFJkLdqDKtgsyCoUvzIAcjhkwvhClgKdxKNcUBgnkoiZVEBo3G8lIgGBR4NxxD9PQwvNhg+g9RTaNgxPAowi0MxuJFHs9Xh5oPgKmnneI2AsdnsE3ayF1UIhuGg8uR6MyMSLsbj8YSypVSe5bala+yfup8A7/oCaManWgYgBhPodOrsdTyTD0N0UWLj5jrDGpqO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EDrWm7CVZaRKBjQZjOWdWW5yDCm2mrWM3wizeXKIlcBDVyLfXKzTdyABhnqWq6N0mqyLBmgPAq1jNRFln1PwTZ6gHXkG0Cap01DnVmtN+am11CfHgEAz4/h+YkBgbQVDObLrXWOzFmLcwADMAgAAcAgACMsRPsxe9n7WYAAWP2tAQdvZBz9t73tZi0Hh59hgfs0Cg5IJD2YX3HsGGO2gGLaBpifemCDmLsRZizAYLEGLIOQcMFmCQWYftVDexB7EEH0xvZoDQHQBgN9GcMGmNjnHjUTu4DOxdq7oFbufGao9oAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

<details open="true">
<summary>🧪 Generate Unit Tests</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Create PR with Unit Tests
- [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Post Copyable Unit Tests in a Comment
- [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Commit Unit Tests in branch `fix-listeners`

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=WFCD/warframe.rs&utm_content=25):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai auto-generate unit tests` to generate unit tests for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
Cargo.toml (1)

35-35: Consider retaining a version alongside the path for warframe-macros.

While cargo ignores the version field for local path dependencies during builds, the field becomes mandatory when you eventually publish the crate to crates.io (path deps are disallowed on publish and must be replaced by a normal dependency). Keeping the version now avoids a future search-and-replace step and documents the intended semver relationship.

If you prefer the leaner manifest locally, ensure you have a release checklist entry that restores the version before publishing.

src/worldstate/client.rs (2)

253-256: Good fix – independent lifetimes unblock async tasks, but update the docs to match.

Changing

for<'a,'b> Callback: AsyncFn(&'a T, &'b T)

removes the “not general enough” error and allows the two references to have unrelated lifetimes. Nice catch.
The surrounding rust-doc comments (lines 220-222) still talk about a single 'any lifetime—worth updating for clarity.

No further issues spotted.


448-451: Same lifetime tweak correctly applied here; documentation again lags behind.

The analogous change to

for<'a,'b> Callback: AsyncFn(S, &'a T, &'b T)

solves the same problem for the stateful variant. Just remember to adjust the doc block above (lines 398-400) so readers don’t see the obsolete 'any wording.

Implementation looks correct.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f5b29d and 66253b8.

📒 Files selected for processing (2)
  • Cargo.toml (1 hunks)
  • src/worldstate/client.rs (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build

@Mettwasser Mettwasser enabled auto-merge (squash) July 6, 2025 16:22
@Mettwasser Mettwasser disabled auto-merge July 6, 2025 16:22
@Mettwasser Mettwasser enabled auto-merge (squash) July 6, 2025 16:23
@Mettwasser Mettwasser disabled auto-merge July 6, 2025 16:44
@Mettwasser Mettwasser enabled auto-merge (squash) July 6, 2025 16:51
@Mettwasser Mettwasser merged commit c22822c into master Jul 6, 2025
4 checks passed
@Mettwasser Mettwasser deleted the fix-listeners branch July 6, 2025 18:38
wfcd-bot-boi pushed a commit that referenced this pull request Jul 6, 2025
## [7.0.1](v7.0.0...v7.0.1) (2025-07-06)

### Bug Fixes

* listeners can now run in tasks ([#25](#25)) ([c22822c](c22822c))
@wfcd-bot-boi
Copy link
Collaborator

🎉 This PR is included in version 7.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants