diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27d1d88..cd1555d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,23 @@ jobs: command: clippy args: --all-targets --all-features -- -D warnings + rustdoc: + name: Rustdoc + runs-on: ubuntu-latest + env: + RUSTDOCFLAGS: -D warnings + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: doc + args: --workspace --no-deps --all-features + minimal-versions: name: Minimal dependency versions runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index e839448..1dceb99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,9 +21,13 @@ This file describes the changes / additions / fixes between wrapper releases, tr ### Documentation * `Device::set_fan_speed()`, `Device::set_default_fan_speed()` and `Device::set_fan_control_policy()` state that they require root/admin permissions and list `NoPermission` among their errors; the NVML header lists `NoPermission` for none of the three (#64) +* The `UnexpectedVariant` entry in 41 error lists, which ended mid-sentence, now reads "check that error's docs for more info" (#151) +* `FanControlPolicy` links to `Device::fan_control_policy()`; the link pointed at a method that does not exist (#151) +* `DetachGpuState` and `PcieLinkState` no longer have a broken link to `Device::remove()` in docs built for a platform other than Linux (#151) ### Internal +* CI builds the docs with `RUSTDOCFLAGS="-D warnings"` (#151) * The `basic_usage` example formats byte counts and PCIe transfer rates itself instead of using the `pretty-bytes` dev-dependency, which pulled in `atty` (RUSTSEC-2024-0375: unmaintained; RUSTSEC-2021-0145: potential unaligned read) (#65, #147) ### Rust Version Support diff --git a/nvml-wrapper/src/device.rs b/nvml-wrapper/src/device.rs index 32d8eb1..a30c9b4 100644 --- a/nvml-wrapper/src/device.rs +++ b/nvml-wrapper/src/device.rs @@ -166,7 +166,7 @@ impl<'nvml> Device<'nvml> { * does not support the feature that is being queried (e.g. enabling/disabling auto * boosted clocks is not supported by this `Device`). * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -238,7 +238,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support auto boosted clocks * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -443,7 +443,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -1285,7 +1285,7 @@ impl<'nvml> Device<'nvml> { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `IncorrectBits`, if bits are found in a session's info flags that don't match the flags in this wrapper * `Uninitialized`, if the library has not been successfully initialized @@ -1435,7 +1435,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error */ // Checked against local @@ -1464,7 +1464,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error */ // Checked against local @@ -1494,7 +1494,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if the platform is not Windows * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -1537,7 +1537,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -1769,7 +1769,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -1799,7 +1799,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -1824,7 +1824,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -1854,7 +1854,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -1988,7 +1988,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid or `fan_idx` is invalid * `NotSupported`, if this `Device` does not have a fan * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -2022,7 +2022,7 @@ impl<'nvml> Device<'nvml> { operation. The NVML header does not list this error for this function. * `NotSupported`, if this `Device` does not have a fan * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -2058,7 +2058,7 @@ impl<'nvml> Device<'nvml> { operation. The NVML header does not list this error for this function. * `NotSupported`, if this `Device` does not have a fan * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -2087,7 +2087,7 @@ impl<'nvml> Device<'nvml> { operation. The NVML header does not list this error for this function. * `NotSupported`, if this `Device` does not have a fan * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -2137,7 +2137,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -2215,7 +2215,7 @@ impl<'nvml> Device<'nvml> { * `Uninitialized`, if the library has not been successfully initialized * `InvalidArg`, if this `Device` is invalid * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error */ // Tested as part of `.running_graphics_processes()` @@ -2288,7 +2288,7 @@ impl<'nvml> Device<'nvml> { * `Uninitialized`, if the library has not been successfully initialized * `InvalidArg`, if this `Device` is invalid * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error */ #[doc(alias = "nvmlDeviceGetGraphicsRunningProcesses_v2")] @@ -3150,7 +3150,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -3183,7 +3183,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` does not support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Platform Support @@ -3525,7 +3525,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if this `Device` is invalid * `NotSupported`, if this `Device` doesn't support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -4162,7 +4162,7 @@ impl<'nvml> Device<'nvml> { * `InvalidArg`, if either `Device` is invalid * `NotSupported`, if this `Device` or the OS does not support this feature - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, an error has occurred in the underlying topology discovery # Platform Support @@ -5029,7 +5029,7 @@ impl<'nvml> Device<'nvml> { * `Uninitialized`, if the library has not been successfully initialized * `InvalidArg`, if the `Device` is invalid * `NotSupported`, if this `Device` does not support this feature - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support @@ -6150,7 +6150,7 @@ impl<'nvml> Device<'nvml> { * `Uninitialized`, if the library has not been successfully initialized * `NotSupported`, if this `Device` doesn't support this feature * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error In addition, all of the errors returned by: diff --git a/nvml-wrapper/src/enum_wrappers/device.rs b/nvml-wrapper/src/enum_wrappers/device.rs index 54889e8..c9c8c81 100644 --- a/nvml-wrapper/src/enum_wrappers/device.rs +++ b/nvml-wrapper/src/enum_wrappers/device.rs @@ -607,7 +607,14 @@ pub enum FbcSessionType { HwEnc, } -/// Options to pass to [`crate::Device::remove()`]. +#[cfg_attr( + target_os = "linux", + doc = "Options to pass to [`crate::Device::remove()`]." +)] +#[cfg_attr( + not(target_os = "linux"), + doc = "Options to pass to `Device::remove()`, which is only available on Linux." +)] #[derive(EnumWrapper, Debug, Clone, Copy, Eq, PartialEq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[wrap(c_enum = "nvmlDetachGpuState_enum")] @@ -618,7 +625,14 @@ pub enum DetachGpuState { Remove, } -/// Options to pass to [`crate::Device::remove()`]. +#[cfg_attr( + target_os = "linux", + doc = "Options to pass to [`crate::Device::remove()`]." +)] +#[cfg_attr( + not(target_os = "linux"), + doc = "Options to pass to `Device::remove()`, which is only available on Linux." +)] #[derive(EnumWrapper, Debug, Clone, Copy, Eq, PartialEq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[wrap(c_enum = "nvmlPcieLinkState_enum")] diff --git a/nvml-wrapper/src/enums/device.rs b/nvml-wrapper/src/enums/device.rs index a60f6b4..8bcbac0 100644 --- a/nvml-wrapper/src/enums/device.rs +++ b/nvml-wrapper/src/enums/device.rs @@ -271,7 +271,7 @@ pub enum DeviceArchitecture { Ada, /// Hopper, - /// https://en.wikipedia.org/wiki/Blackwell_(microarchitecture) + /// Blackwell, /// Unknown device architecture (most likely something newer). Unknown, @@ -405,7 +405,7 @@ pub enum FanControlPolicy { Manual = NVML_FAN_POLICY_MANUAL, } -/// Returned by [`crate::Device::get_fan_control_policy()`]. +/// Returned by [`crate::Device::fan_control_policy()`]. /// /// Policy used for fan control. // TODO: technically this is an "enum wrapper" but the type on the C side isn't diff --git a/nvml-wrapper/src/enums/unit.rs b/nvml-wrapper/src/enums/unit.rs index 7bb8e95..5990b4b 100644 --- a/nvml-wrapper/src/enums/unit.rs +++ b/nvml-wrapper/src/enums/unit.rs @@ -22,7 +22,7 @@ impl TryFrom for LedState { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlLedState_t) -> Result { let color = value.color; diff --git a/nvml-wrapper/src/lib.rs b/nvml-wrapper/src/lib.rs index fa223c3..d0925b3 100644 --- a/nvml-wrapper/src/lib.rs +++ b/nvml-wrapper/src/lib.rs @@ -693,7 +693,7 @@ impl Nvml { * `InvalidArg`, if the device is invalid * `NotSupported`, if this `Device` or the OS does not support this feature - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Platform Support diff --git a/nvml-wrapper/src/nv_link.rs b/nvml-wrapper/src/nv_link.rs index b0858cc..3470ca9 100644 --- a/nvml-wrapper/src/nv_link.rs +++ b/nvml-wrapper/src/nv_link.rs @@ -76,7 +76,7 @@ impl<'device, 'nvml: 'device> NvLink<'device, 'nvml> { * `InvalidArg`, if the `link` or `Device` within this `NvLink` struct instance is invalid * `NotSupported`, if this `Device` doesn't support this feature - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support diff --git a/nvml-wrapper/src/struct_wrappers/device.rs b/nvml-wrapper/src/struct_wrappers/device.rs index 6b3101f..b31646b 100644 --- a/nvml-wrapper/src/struct_wrappers/device.rs +++ b/nvml-wrapper/src/struct_wrappers/device.rs @@ -173,7 +173,7 @@ impl TryFrom for BridgeChipInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlBridgeChipInfo_t) -> Result { let fw_version = FirmwareVersion::from(value.fwVersion); @@ -210,7 +210,7 @@ impl TryFrom for BridgeChipHierarchy { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlBridgeChipHierarchy_t) -> Result { let chips_hierarchy = value @@ -464,7 +464,7 @@ impl TryFrom for EncoderSessionInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlEncoderSessionInfo_t) -> Result { Ok(Self { @@ -564,7 +564,7 @@ impl TryFrom for FieldValueSample { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlFieldValue_t) -> Result { Ok(Self { @@ -644,7 +644,7 @@ impl TryFrom for FbcSessionInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info * `IncorrectBits`, if the `sessionFlags` from the given struct do match the wrapper definition */ diff --git a/nvml-wrapper/src/struct_wrappers/mod.rs b/nvml-wrapper/src/struct_wrappers/mod.rs index d3940a9..6190738 100644 --- a/nvml-wrapper/src/struct_wrappers/mod.rs +++ b/nvml-wrapper/src/struct_wrappers/mod.rs @@ -28,7 +28,7 @@ impl TryFrom for ExcludedDeviceInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlExcludedDeviceInfo_t) -> Result { unsafe { diff --git a/nvml-wrapper/src/struct_wrappers/nv_link.rs b/nvml-wrapper/src/struct_wrappers/nv_link.rs index a51b815..ac8234d 100644 --- a/nvml-wrapper/src/struct_wrappers/nv_link.rs +++ b/nvml-wrapper/src/struct_wrappers/nv_link.rs @@ -37,7 +37,7 @@ impl TryFrom for UtilizationControl { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlNvLinkUtilizationControl_t) -> Result { let bits = value.pktfilter; diff --git a/nvml-wrapper/src/struct_wrappers/unit.rs b/nvml-wrapper/src/struct_wrappers/unit.rs index 3f5f6ae..893a8ae 100644 --- a/nvml-wrapper/src/struct_wrappers/unit.rs +++ b/nvml-wrapper/src/struct_wrappers/unit.rs @@ -24,7 +24,7 @@ impl TryFrom for FansInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlUnitFanSpeeds_t) -> Result { let fans = value @@ -59,7 +59,7 @@ impl TryFrom for FanInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlUnitFanInfo_t) -> Result { Ok(FanInfo { @@ -108,7 +108,7 @@ impl TryFrom for PsuInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlPSUInfo_t) -> Result { unsafe { @@ -144,7 +144,7 @@ impl TryFrom for UnitInfo { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlUnitInfo_t) -> Result { unsafe { @@ -180,7 +180,7 @@ impl TryFrom for HwbcEntry { # Errors - * `UnexpectedVariant`, for which you can read the docs for + * `UnexpectedVariant`, check that error's docs for more info */ fn try_from(value: nvmlHwbcEntry_t) -> Result { unsafe { diff --git a/nvml-wrapper/src/unit.rs b/nvml-wrapper/src/unit.rs index 18e32f1..7cfaa36 100644 --- a/nvml-wrapper/src/unit.rs +++ b/nvml-wrapper/src/unit.rs @@ -166,7 +166,7 @@ impl<'nvml> Unit<'nvml> { * `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 + * `UnexpectedVariant`, check that error's docs for more info * `Unknown`, on any unexpected error # Device Support