Skip to content

Pluggable Async Runtime: AsyncManager Trait + spawn! Macro#839

Merged
qdot merged 10 commits intobuttplugio:devfrom
jsmnbom:feature/async-manager-trait
Mar 16, 2026
Merged

Pluggable Async Runtime: AsyncManager Trait + spawn! Macro#839
qdot merged 10 commits intobuttplugio:devfrom
jsmnbom:feature/async-manager-trait

Conversation

@jsmnbom
Copy link

@jsmnbom jsmnbom commented Mar 15, 2026

Part of the work on #833, split into smaller PR as recommended. See #833 for motivation.

Replaces the compile-time cfg_if-based async runtime dispatch in buttplug_core with a dynamic, pluggable AsyncManager trait backed by a global OnceLock. This is the foundation for supporting alternative async runtimes (e.g. esp-idf-hal for embedded) without requiring upstream dependencies in buttplug_core.

I feel like a trait + global implementation is best for the library since the other alternatives i can think of are:

  • Upstream depending on specific esoteric runtime crates (esp-idf-hal)
  • unsafe extern "Rust" fn
  • Restructuring the entire libary to use only future combinators
  • Making ButtplugClient, ButtplugServer and a ton more types generic over a runtime.

All of which have clear downsides in my opinion.

I do not think any further tests are needed for this change. Ideally wasm would be testing as part of CI, but if anything this change may make that slightly easier to implement in the future :)

@qdot qdot changed the base branch from master to dev March 16, 2026 02:03
@qdot qdot merged commit ddd6e8f into buttplugio:dev Mar 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants