Skip to content

Commit

Permalink
Add Litra::refresh_connected_devices() function to refresh the cach…
Browse files Browse the repository at this point in the history
…ed list of connected Litra devices

Fixes #108.
  • Loading branch information
timrogers committed Nov 3, 2024
1 parent 4be2713 commit fb885c7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ impl Litra {
Ok(Litra(hidapi))
}

/// Returns an [`Iterator`] of connected devices supported by this library.
/// Returns an [`Iterator`] of cached connected devices supported by this library. To refresh the list of connected devices, use [`Litra::refresh_connected_devices`].
pub fn get_connected_devices(&self) -> impl Iterator<Item = Device<'_>> {
self.0
.device_list()
.filter_map(|device_info| Device::try_from(device_info).ok())
}

/// Refreshes the list of connected devices, returned by [`Litra::get_connected_devices`].
pub fn refresh_connected_devices(&mut self) -> DeviceResult<()> {
self.0.refresh_devices()?;
Ok(())
}

/// Retrieve the underlying hidapi context.
#[must_use]
pub fn hidapi(&self) -> &HidApi {
Expand Down

0 comments on commit fb885c7

Please sign in to comment.