[][src]Crate cue_sdk

cue-sdk - A safe wrapper for the Corsair iCUE SDK.

cue-sdk provides core functionality for interfacing with the Corsair iCUE SDK, through the cue-sdk-sys crate.

Quick Start

Make sure you set the required environment variables for the cue-sdk-sys dependency crate.

If you need the binaries, the easiest place to get them is on the Github Releases Page. Since we can't build them from scratch (not open source) you have to get them yourself.

This version of the crate is built against version 3.0.55 of the iCUE SDK.

Example Code

use cue_sdk::led::LedColor;
use cue_sdk::initialize;
let sdk = initialize()
    .expect("failed to initialize sdk");
let mut  devices = sdk.get_all_devices().expect("failed to get all devices");
let new_color = LedColor { red: 200, green: 20, blue: 165 };
for d in &mut devices {
    //print some info
    println!("Device: {:?} at index {:?} has led count: ${:?}",
        d.device_info.model, d.device_index, d.leds.len());

    // set the first led in every device to our `new_color` color
    d.leds.first_mut().unwrap().update_color_buffer(new_color);
}
//flush the colors buffer (send to device hardware)
sdk.flush_led_colors_update_buffer_sync()
    .expect("failed to flush led buffer");

You can note from the following example, most "write" operations can fail for a variety of reasons including but not limited to:

  • device state changes (devices have been unplugged/plugged in)
  • ffi interfacing (pointer derefs, etc) fail due to undocumented breaking changes in the iCUE SDK, or a bug in the crate code
  • another client has requested exclusive access

Examples

For additional examples see the example code and run examples with cargo run --example {example_name}.

Modules

device

Contains the CueDevice struct, it's methods, errors, and other "device related" structs and functionality, including channels, device layout and capabilities, and more.

errors

Contains the top level SDK error type, and Result type.

event

Contains the event types, and event errors that can be returned from the iCUE SDK.

initialization
key

Contains the KeyId enum, with all of the key identifiers that are supported from the iCUE SDK.

led

Contains the CueLed struct, and all of it's associated functionality and errors.

property

Int32 and Boolean property structs, for reading various device properties for devices with property lookup functionality.

sdk

Top-level SDK functionality, including getting devices, writing and flushing color buffers, and subscribing to events.

Functions

initialize

This is the single and only way currently to initialize the SDK.