Expand description

A convenient abstraction for working with events.

Simply register the devices you wish to receive events for and then compose a handler for the events. Event handling looks like this (details removed):

event_loop.run_forever(|event, state| match event {
    // If there were no errors, extract the event
    Ok(event) => match event {
        ClockChange(device) => { /* ... */ },
        PowerStateChange(device) => { /* ... */ },
        _ => { /* ... */ }
    },

    // If there was an error, handle it
    Err(error) => match error {
        // If the error is `Unknown`, continue looping and hope for the best
        NvmlError::Unknown => {},
        // The other errors that can occur are almost guaranteed to mean that
        // further looping will never be successful (`GpuLost` and
        // `Uninitialized`), so we stop looping
        _ => state.interrupt()
    }
});

The full, fleshed-out example can be viewed in the examples directory (event_loop.rs). Run it as follows:

cargo run --example event_loop

The functionality in this module is only available on Linux platforms; NVML does not support events on any other platform.

Structs§

  • Holds the EventSet utilized within an event loop.
  • Keeps track of whether an EventLoop is interrupted or not.

Enums§

  • Represents the event types that an EventLoop can gather for you.

Traits§