Skip to main content

Receiver

Struct Receiver 

Source
pub struct Receiver { /* private fields */ }
Expand description

Implements the Bolt receiver.

Implementations§

Source§

impl Receiver

Source

pub fn new(chan: Arc<HidppChannel>) -> Result<Self, ReceiverError>

Tries to initialize a new Receiver from a raw HID++ channel.

If no receiver could be found, or if the vendor and product IDs don’t match the ones of any known Bolt receiver, this function will return ReceiverError::UnknownReceiver.

Source

pub fn listen(&self) -> Receiver<Event>

Creates a new listener for receiving receiver events.

Source

pub async fn get_notification_state( &self, ) -> Result<NotificationState, ReceiverError>

Queries the current information about what notifications are enabled.

Source

pub async fn set_notification_state( &self, state: NotificationState, ) -> Result<(), ReceiverError>

Configures what notifications are enabled and thus reported by the receiver.

Source

pub async fn count_pairings(&self) -> Result<u8, ReceiverError>

Counts the amount of devices currently paired to this receiver. The devices don’t have to be online to be included here as pairings are persistent.

Source

pub async fn trigger_device_arrival(&self) -> Result<(), ReceiverError>

Triggers device arrival notifications for all devices currently connected to the receiver. This is useful for device enumeration.

Check Self::get_notification_state first to make sure that NotificationState::wireless_notifications is enabled.

Source

pub async fn collect_paired_devices( &self, ) -> Result<Vec<DeviceConnection>, ReceiverError>

Collects information about all paired devices by calling Self::trigger_device_arrival and collecting incoming Event::DeviceConnection events.

Check Self::get_notification_state first to make sure that NotificationState::wireless_notifications is enabled.

Source

pub async fn get_unique_id(&self) -> Result<String, ReceiverError>

Retrieves the unique ID of the receiver. This is not the same as the serial number.

Source

pub async fn get_device_pairing_information( &self, device_index: u8, ) -> Result<DevicePairingInformation, ReceiverError>

Provides the pairing information of a specific paired device by its index.

Source

pub async fn get_device_codename( &self, device_index: u8, ) -> Result<String, ReceiverError>

Provides the codename of a specific paired device by its index.

Source

pub async fn unpair_device(&self, device_index: u8) -> Result<(), ReceiverError>

Unpairs a device from the receiver by its index.

Source

pub async fn pair_device( &self, slot: u8, address: [u8; 6], authentication: u8, entropy: u8, ) -> Result<(), ReceiverError>

Starts the pairing process for a new device.

The required address and authentication values are usually discovered from the Event::DeviceDiscoveryDeviceDetails event which is emitted regularly when actively discovering available devices (Self::discover_devices).

entropy specifies how complex the authentication passkey should be. For mice, this defines the amount of keypresses (left or right) the user has to perform. Not all values seem to be supported.

Source

pub async fn discover_devices( &self, timeout: Option<u8>, ) -> Result<(), ReceiverError>

Starts device discovery for timeout seconds (None = default, seems to be 30s). The maximum supported value is 60s.

While device discovery is enabled, Event::DeviceDiscoveryDeviceDetails and Event::DeviceDiscoveryDeviceName events are emitted for every discovered device.

Source

pub async fn cancel_device_discovery(&self) -> Result<(), ReceiverError>

Cancels the device discovery process.

Trait Implementations§

Source§

impl Clone for Receiver

Source§

fn clone(&self) -> Receiver

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 Drop for Receiver

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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