Skip to content

Conversation

@AlfioEmanueleFresta
Copy link
Member

Requires #126.

Changes:

  • Moves UX updates to Channel, so that Device::channel() no longer needs to return a tuple (Channel, Channel::UxUpdate)
  • Changes updates channel implementation from multi-producer, single-consumer mpsc to broadcast, allowing subscribing more than once. This allows subscribing to events without borrowing the channel mutably
  • Wraps PIN entry callback with Arc, and makes all UxUpdates Clone, as broadcast requires the message to be Clone

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the UX updates system by moving responsibility from the Device trait to the Channel trait. The main goal is to eliminate the need for Device::channel() to return a tuple and enable multiple subscribers to UX updates.

Key changes:

  • Refactors Device::channel() to return only the channel instead of a (Channel, Receiver) tuple
  • Switches from multi-producer single-consumer (mpsc) to broadcast channels for UX updates
  • Wraps PIN entry callbacks with Arc to satisfy Clone requirements for broadcast messages

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
libwebauthn/src/transport/device.rs Updates Device trait to return only Channel from channel() method
libwebauthn/src/transport/channel.rs Adds broadcast sender/receiver methods and updates UX update handling
libwebauthn/src/transport/hid/device.rs Implements simplified channel() method for HID devices
libwebauthn/src/transport/hid/channel.rs Updates HID channel to use broadcast for UX updates
libwebauthn/src/transport/cable/*.rs Updates Cable transport implementation for broadcast UX updates
libwebauthn/src/transport/ble/*.rs Updates BLE transport implementation for broadcast UX updates
libwebauthn/src/lib.rs Makes UX update types Clone and wraps PIN callback with Arc
libwebauthn/examples/*.rs Updates examples to use new channel API pattern

@AlfioEmanueleFresta
Copy link
Member Author

Rebased.

Copy link
Collaborator

@msirringhaus msirringhaus left a comment

Choose a reason for hiding this comment

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

Left one small comment/question about the Arc-usage.

Otherwise looking good.

@AlfioEmanueleFresta AlfioEmanueleFresta merged commit de11920 into master Jul 21, 2025
4 checks passed
@AlfioEmanueleFresta AlfioEmanueleFresta deleted the ux-errors-1 branch July 21, 2025 14:42
AlfioEmanueleFresta added a commit that referenced this pull request Jul 21, 2025
Requires #128.

* Surfaces asynchronous transport errors via `CableUxUpdate::Error`.
* All Cable errors to use `TransportError`, rather than the generic
`Error`.
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.

3 participants