nvml_wrapper/enum_wrappers/
mod.rs1use crate::error::NvmlError;
2use crate::ffi::bindings::*;
3
4pub mod device;
5pub mod nv_link;
6pub mod unit;
7pub mod vgpu;
8
9pub fn bool_from_state(state: nvmlEnableState_t) -> Result<bool, NvmlError> {
10 match state {
11 nvmlEnableState_enum_NVML_FEATURE_DISABLED => Ok(false),
12 nvmlEnableState_enum_NVML_FEATURE_ENABLED => Ok(true),
13 _ => Err(NvmlError::UnexpectedVariant(state)),
14 }
15}
16
17pub fn state_from_bool(enabled: bool) -> nvmlEnableState_t {
18 if enabled {
19 nvmlEnableState_enum_NVML_FEATURE_ENABLED
20 } else {
21 nvmlEnableState_enum_NVML_FEATURE_DISABLED
22 }
23}