Skip to main content

Session

Struct Session 

Source
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

Source

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.

Source

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).

Source

pub fn details(&self) -> Result<SessionDetails>

Get the current session details (client/server/host versions).

Source

pub fn get_devices(&self, filter: DeviceType) -> Result<Vec<DeviceInfo>>

Enumerate connected devices matching the given type filter.

Source

pub fn get_device_info(&self, device_id: &DeviceId) -> Result<DeviceInfo>

Get detailed information about a specific device.

Source

pub fn get_led_positions( &self, device_id: &DeviceId, ) -> Result<Vec<LedPosition>>

Get the positions of all LEDs on a device.

Source

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.

Source

pub fn set_led_colors_buffer( &self, device_id: &DeviceId, colors: &[LedColor], ) -> Result<()>

Buffer LED colors for later flushing with flush_led_colors.

Source

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.

Source

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.

Source

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.

Source

pub fn set_layer_priority(&self, priority: u32) -> Result<()>

Set the layer priority for this client (0–255).

Source

pub fn request_control( &self, device_id: &DeviceId, level: AccessLevel, ) -> Result<()>

Request exclusive control of a device.

Source

pub fn release_control(&self, device_id: &DeviceId) -> Result<()>

Release exclusive control of a device.

Source

pub fn subscribe_for_events(&self) -> Result<EventSubscription>

Subscribe to SDK events (device connect/disconnect, key events).

Returns an EventSubscription which unsubscribes on drop.

Source

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.

Source

pub fn get_device_property_info( &self, device_id: &DeviceId, property: PropertyId, index: u32, ) -> Result<PropertyInfo>

Get metadata about a device property.

Source

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.

Source

pub fn write_device_property_bool( &self, device_id: &DeviceId, property: PropertyId, index: u32, value: bool, ) -> Result<()>

Write a boolean property to a device.

Source

pub fn write_device_property_int32( &self, device_id: &DeviceId, property: PropertyId, index: u32, value: i32, ) -> Result<()>

Write an integer property to a device.

Source

pub fn write_device_property_float64( &self, device_id: &DeviceId, property: PropertyId, index: u32, value: f64, ) -> Result<()>

Write a float property to a device.

Trait Implementations§

Source§

impl Drop for Session

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Session

Source§

impl Sync for Session

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> 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, 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.