pub enum DeviceStableId {
Bolt {
receiver_uid: String,
slot: u8,
},
Direct {
vendor_id: u16,
product_id: u16,
identity: DeviceIdentity,
},
RawHid {
vendor_id: u16,
product_id: u16,
usage_page: u16,
usage_id: u16,
identity: String,
},
Unknown {
slot: u8,
identity: DeviceIdentity,
},
}Expand description
A route-derived identity used to order devices deterministically.
Receiver UID + slot and serial/non-zero unit identities are stable and
unique. OS-node identities on raw HID routes are deliberately retained here
only so a transient inventory record can still be ordered; they cannot
become a PhysicalDeviceKey.
Variants§
Bolt
Paired to a receiver — Bolt and Unifying share this variant so order agrees regardless of receiver family.
Direct
Attached straight to the host (USB or Bluetooth), disambiguated by its
own DeviceIdentity.
Fields
identity: DeviceIdentityDisambiguates two same-model direct devices.
RawHid
A standalone raw-HID device, addressed by its USB/usage identifiers plus an OS-node- or serial-derived identity string.
Fields
Unknown
No route was reported; ordered by pairing slot plus its own
DeviceIdentity.
Fields
identity: DeviceIdentityDisambiguates two same-model routeless devices.
Implementations§
Source§impl DeviceStableId
impl DeviceStableId
Sourcepub fn from_parts(
route: Option<&DeviceRoute>,
slot: u8,
serial: Option<&str>,
unit_id: [u8; 4],
) -> Self
pub fn from_parts( route: Option<&DeviceRoute>, slot: u8, serial: Option<&str>, unit_id: [u8; 4], ) -> Self
Build the stable id from a device’s route plus its identity fields.
slot is only consulted for a routeless device (the Bolt/Direct cases
carry their own slot / addressing inside the route).
Sourcepub fn runtime_key(&self) -> String
pub fn runtime_key(&self) -> String
Route-derived key used while a device is present in a runtime snapshot.
Unlike Self::physical_key, this also represents a direct or
routeless device whose only reported identity is an all-zero unit id.
Such a key is suitable for short-lived UI bookkeeping only and must not
be written to configuration.
This intentionally keys receiver-connected devices by receiver UID + pairing slot rather than model id, so two identical mice paired to the same receiver can carry different settings.
Sourcepub fn physical_key(&self) -> Option<PhysicalDeviceKey>
pub fn physical_key(&self) -> Option<PhysicalDeviceKey>
Stable key for persisted per-physical-device configuration.
Receiver-connected devices are identified by receiver UID + pairing slot. Direct and routeless devices require either a non-empty serial number or a non-zero unit id. Raw HID devices require a serial-backed route identity; OS node identities and all-zero unit ids are transient probe results, not physical identities.
Trait Implementations§
Source§impl Clone for DeviceStableId
impl Clone for DeviceStableId
Source§fn clone(&self) -> DeviceStableId
fn clone(&self) -> DeviceStableId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DeviceStableId
impl Debug for DeviceStableId
impl Eq for DeviceStableId
Source§impl Ord for DeviceStableId
impl Ord for DeviceStableId
Source§fn cmp(&self, other: &DeviceStableId) -> Ordering
fn cmp(&self, other: &DeviceStableId) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for DeviceStableId
impl PartialEq for DeviceStableId
Source§impl PartialOrd for DeviceStableId
impl PartialOrd for DeviceStableId
impl StructuralPartialEq for DeviceStableId
Auto Trait Implementations§
impl Freeze for DeviceStableId
impl RefUnwindSafe for DeviceStableId
impl Send for DeviceStableId
impl Sync for DeviceStableId
impl Unpin for DeviceStableId
impl UnsafeUnpin for DeviceStableId
impl UnwindSafe for DeviceStableId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.