pub struct Session { /* private fields */ }Expand description
A connected session to the iCUE SDK.
All SDK operations are methods on this struct. Dropping the session calls
CorsairDisconnect.
Only one Session should exist at a time per process.
Implementations§
Source§impl Session
impl Session
Sourcepub fn connect() -> Result<Self>
pub fn connect() -> Result<Self>
Initiate a connection to iCUE.
This registers the session-state callback and calls CorsairConnect.
Use wait_for_connection afterwards to
block until the session reaches the Connected state.
Sourcepub fn wait_for_connection(&self, timeout: Duration) -> Result<SessionDetails>
pub fn wait_for_connection(&self, timeout: Duration) -> Result<SessionDetails>
Block until the session state becomes Connected or the timeout
elapses.
On success returns the SessionDetails that were provided with the
Connected state change.
Returns Err(SdkError::NotConnected) on timeout or if the session
enters a terminal error state (refused, lost).
Sourcepub fn details(&self) -> Result<SessionDetails>
pub fn details(&self) -> Result<SessionDetails>
Get the current session details (client/server/host versions).
Sourcepub fn get_devices(&self, filter: DeviceType) -> Result<Vec<DeviceInfo>>
pub fn get_devices(&self, filter: DeviceType) -> Result<Vec<DeviceInfo>>
Enumerate connected devices matching the given type filter.
Sourcepub fn get_device_info(&self, device_id: &DeviceId) -> Result<DeviceInfo>
pub fn get_device_info(&self, device_id: &DeviceId) -> Result<DeviceInfo>
Get detailed information about a specific device.
Sourcepub fn get_led_positions(
&self,
device_id: &DeviceId,
) -> Result<Vec<LedPosition>>
pub fn get_led_positions( &self, device_id: &DeviceId, ) -> Result<Vec<LedPosition>>
Get the positions of all LEDs on a device.
Sourcepub fn set_led_colors(
&self,
device_id: &DeviceId,
colors: &[LedColor],
) -> Result<()>
pub fn set_led_colors( &self, device_id: &DeviceId, colors: &[LedColor], ) -> Result<()>
Set LED colors on a device immediately.
colors must be a slice of LedColor with the LED LUIDs set
correctly for the target device.
Sourcepub fn set_led_colors_buffer(
&self,
device_id: &DeviceId,
colors: &[LedColor],
) -> Result<()>
pub fn set_led_colors_buffer( &self, device_id: &DeviceId, colors: &[LedColor], ) -> Result<()>
Buffer LED colors for later flushing with
flush_led_colors.
Sourcepub fn flush_led_colors(&self) -> Result<()>
pub fn flush_led_colors(&self) -> Result<()>
Flush all buffered LED color changes.
This is a synchronous wrapper around CorsairSetLedColorsFlushBufferAsync:
it blocks until the SDK signals completion.
Sourcepub fn get_led_colors(
&self,
device_id: &DeviceId,
colors: &mut [LedColor],
) -> Result<()>
pub fn get_led_colors( &self, device_id: &DeviceId, colors: &mut [LedColor], ) -> Result<()>
Read current LED colors from a device.
The colors slice must have the id field of each element pre-set to
the LED LUID to query; the SDK fills in the r, g, b, a values.
Sourcepub fn get_led_luid_for_key_name(
&self,
device_id: &DeviceId,
key_name: c_char,
) -> Result<u32>
pub fn get_led_luid_for_key_name( &self, device_id: &DeviceId, key_name: c_char, ) -> Result<u32>
Look up the LED LUID for a key name character on a keyboard device.
Sourcepub fn set_layer_priority(&self, priority: u32) -> Result<()>
pub fn set_layer_priority(&self, priority: u32) -> Result<()>
Set the layer priority for this client (0–255).
Sourcepub fn request_control(
&self,
device_id: &DeviceId,
level: AccessLevel,
) -> Result<()>
pub fn request_control( &self, device_id: &DeviceId, level: AccessLevel, ) -> Result<()>
Request exclusive control of a device.
Sourcepub fn release_control(&self, device_id: &DeviceId) -> Result<()>
pub fn release_control(&self, device_id: &DeviceId) -> Result<()>
Release exclusive control of a device.
Sourcepub fn subscribe_for_events(&self) -> Result<EventSubscription>
pub fn subscribe_for_events(&self) -> Result<EventSubscription>
Subscribe to SDK events (device connect/disconnect, key events).
Returns an EventSubscription which unsubscribes on drop.
Sourcepub fn configure_key_event(
&self,
device_id: &DeviceId,
key_id: MacroKeyId,
is_intercepted: bool,
) -> Result<()>
pub fn configure_key_event( &self, device_id: &DeviceId, key_id: MacroKeyId, is_intercepted: bool, ) -> Result<()>
Configure whether a macro key event should be intercepted.
Sourcepub fn get_device_property_info(
&self,
device_id: &DeviceId,
property: PropertyId,
index: u32,
) -> Result<PropertyInfo>
pub fn get_device_property_info( &self, device_id: &DeviceId, property: PropertyId, index: u32, ) -> Result<PropertyInfo>
Get metadata about a device property.
Sourcepub fn read_device_property(
&self,
device_id: &DeviceId,
property: PropertyId,
index: u32,
) -> Result<PropertyValue>
pub fn read_device_property( &self, device_id: &DeviceId, property: PropertyId, index: u32, ) -> Result<PropertyValue>
Read a device property value.
The SDK-allocated memory is freed immediately after the value is copied
into an owned PropertyValue.
Sourcepub fn write_device_property_bool(
&self,
device_id: &DeviceId,
property: PropertyId,
index: u32,
value: bool,
) -> Result<()>
pub fn write_device_property_bool( &self, device_id: &DeviceId, property: PropertyId, index: u32, value: bool, ) -> Result<()>
Write a boolean property to a device.
Sourcepub fn write_device_property_int32(
&self,
device_id: &DeviceId,
property: PropertyId,
index: u32,
value: i32,
) -> Result<()>
pub fn write_device_property_int32( &self, device_id: &DeviceId, property: PropertyId, index: u32, value: i32, ) -> Result<()>
Write an integer property to a device.
Sourcepub fn write_device_property_float64(
&self,
device_id: &DeviceId,
property: PropertyId,
index: u32,
value: f64,
) -> Result<()>
pub fn write_device_property_float64( &self, device_id: &DeviceId, property: PropertyId, index: u32, value: f64, ) -> Result<()>
Write a float property to a device.