pub struct Unit<'nvml> { /* private fields */ }
Expand description

Struct that represents a unit.

Obtain a Unit with the various methods available to you on the Nvml struct.

Lifetimes are used to enforce that each Unit instance cannot be used after the Nvml instance it was obtained from is dropped:

use nvml_wrapper::Nvml;

let nvml = Nvml::init()?;
let unit = nvml.unit_by_index(0)?;

drop(nvml);

// This won't compile
let unit_devices = unit.devices()?;

Note that I cannot test any Unit methods myself as I do not have access to such hardware. Test the functionality in this module before you use it.

Implementations

Create a new Unit wrapper.

You will most likely never need to call this; see the methods available to you on the Nvml struct to get one.

Safety

It is your responsibility to ensure that the given nvmlUnit_t pointer is valid.

Access the NVML reference this struct wraps

Get the raw unit handle contained in this struct

Sometimes necessary for C interop.

Safety

This is unsafe to prevent it from being used without care.

Gets the set of GPU devices that are attached to this Unit.

I do not have the hardware to test this call. Verify for yourself that it works before you use it. If it works, please let me know; if it doesn’t, I would love a PR. If NVML is sane this should work, but NVIDIA’s docs on this call are anything but clear.

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • Unknown, on any unexpected error
Device Support

For S-class products.

Gets the count of GPU devices that are attached to this Unit.

I do not have the hardware to test this call. Verify for yourself that it works before you use it. If it works, please let me know; if it doesn’t, I would love a PR. If NVML is sane this should work, but NVIDIA’s docs on this call are anything but clear.

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • Unknown, on any unexpected error
Device Support

For S-class products.

Gets fan information for this Unit (fan count and state + speed for each).

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • NotSupported, if this is not an S-class product
  • UnexpectedVariant, for which you can read the docs for
  • Unknown, on any unexpected error
Device Support

For S-class products.

Gets the LED state associated with this Unit.

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • NotSupported, if this is not an S-class product
  • Utf8Error, if the string obtained from the C function is not valid Utf8
  • Unknown, on any unexpected error
Device Support

For S-class products.

Gets the PSU stats for this Unit.

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • NotSupported, if this is not an S-class product
  • Utf8Error, if the string obtained from the C function is not valid Utf8
  • Unknown, on any unexpected error
Device Support

For S-class products.

Gets the temperature for the specified UnitTemperatureReading, in °C.

Available readings depend on the product.

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • NotSupported, if this is not an S-class product
  • Unknown, on any unexpected error
Device Support

For S-class products. Available readings depend on the product.

Gets the static information associated with this Unit.

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • Utf8Error, if the string obtained from the C function is not valid Utf8
Device Support

For S-class products.

Sets the LED color for this Unit.

Requires root/admin permissions. This operation takes effect immediately.

Note: Current S-class products don’t provide unique LEDs for each unit. As such, both front and back LEDs will be toggled in unison regardless of which unit is specified with this method (aka the Unit represented by this struct).

Errors
  • Uninitialized, if the library has not been successfully initialized
  • InvalidArg, if the unit is invalid
  • NotSupported, if this is not an S-class product
  • NoPermission, if the user doesn’t have permission to perform this operation
  • Unknown, on any unexpected error
Device Support

For S-class products.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.