Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event { DeviceConnection(DeviceConnection), DeviceDiscoveryStatus { discovery_enabled: bool, }, DeviceDiscoveryDeviceDetails { counter: u16, kind: DeviceKind, wpid: u16, address: [u8; 6], authentication: u8, }, DeviceDiscoveryDeviceName { counter: u16, name: String, }, PairingStatus { device_address: [u8; 6], pairing_error: Option<PairingError>, slot: Option<u8>, }, PairingPasskeyRequest { device_address: [u8; 6], passkey: String, }, PairingPasskeyPressed { device_address: [u8; 6], press_type: PairingPasskeyPressType, }, }
Expand description

Represents an event emitted by the receiver.

You can listen to these events using Receiver::listen. Only enabled notifications as indicated by Receiver::get_notification_state are emitted.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

DeviceConnection(DeviceConnection)

Is emitted whenever a device connects to or disconnects from the receiver, but only if NotificationState::wireless_notifications is enabled.

Can be triggered for all paired devices using Receiver::trigger_device_arrival to allow easy device enumeration.

Receiver::collect_paired_devices implements a simple mechanism to collect all paired devices.

§

DeviceDiscoveryStatus

Is emitted whenever the device discovery status changes.

Fields

§discovery_enabled: bool
§

DeviceDiscoveryDeviceDetails

Is emitted many times for every device discovered using Receiver::discover_devices.

This event contains device details, including its address required to start pairing. The Event::DeviceDiscoveryDeviceName event will also be emitted and contains the device name.

Fields

§counter: u16

The incrementing event counter. This can be used to map Event::DeviceDiscoveryDeviceDetails and Event::DeviceDiscoveryDeviceName events.

§wpid: u16
§address: [u8; 6]

The address of the device required to pair it using Receiver::pair_device.

This can also be used as the unique device identifier when collecting discovered devices.

§authentication: u8

The authentication type(s) the device supports. Unfortunately, there is not much information about this value and whether it is a single value or a bitfield.

§

DeviceDiscoveryDeviceName

Is emitted many times for every device discovered using Receiver::discover_devices.

This event only contains the device name. Device details will be provided using the Event::DeviceDiscoveryDeviceDetails event.

Fields

§counter: u16

The incrementing event counter. This can be used to map Event::DeviceDiscoveryDeviceDetails and Event::DeviceDiscoveryDeviceName events.

§name: String
§

PairingStatus

Is emitted whenever the status of a pairing process changes.

Fields

§device_address: [u8; 6]
§pairing_error: Option<PairingError>
§slot: Option<u8>

The receiver slot the newly paired device was paired to. This can be used as the device index for subsequent operations.

§

PairingPasskeyRequest

Is emitted once the receiver requests a passkey to be entered on a device that should be paired to it.

Fields

§device_address: [u8; 6]
§passkey: String

The passkey the user has to enter in order to pair the device.

Depending on the device and authentication type, this value has different implications.

For mice, this value will be a valid 6-digit number. After parsing this into an integer, the (least significant) bits represent the sequence of mouse presses (0 = left, 1 = right) the user has to perform, with an additional press of both mouse buttons simultaneously.

The amount of bits significant to this equals to the entropy passed to Receiver::pair_device.

§

PairingPasskeyPressed

Is emitted for every keypress a user performs while entering a pairing passkey.

Fields

§device_address: [u8; 6]
§press_type: PairingPasskeyPressType

The type of the keypress the user performed.

Every passkey sequence starts with an event where this value is set to PairingPasskeyPressType::Initialization. Each time the user presses a key, an event with a press type of PairingPasskeyPressType::Keypress is emitted. Once the user submits their passkey, this value will be PairingPasskeyPressType::Submit.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Event

Source§

impl Hash for Event

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V