Expand description
§sensors-sys: Unsafe Rust bindings for libsensors
lm-sensors provides user-space support for the hardware monitoring drivers
in Linux.
This crate is Linux-specific. Building it for non-Linux platforms, or for the Linux kernel, results in an empty crate.
This crate links to libsensors, and requires it to be installed.
See below for example installation instructions.
§Installing libsensors
This crate links to libsensors, and requires it to be installed.
The library, its C header files, and the clang compiler need to be installed on the build machine.
On Debian, for example, one can install that as follows:
$ sudo apt install clang libsensors-devIf the library is linked dynamically (most typical configuration), then it needs to be installed on the target computer in order to run the resulting program. On Debian, for example, one can install it as follows:
$ sudo apt install libsensors5§Supported environment variables
This crate depends on some environment variables, and variants of those.
For each environment variable (e.g., CC), the following are the accepted
variants of it:
<var>_<target>, e.g.,CC_aarch64-unknown-linux-gnu.<var>_<target-with-underscores>, e.g.,CC_aarch64_unknown_linux_gnu.TARGET_<var>, e.g.,TARGET_CC.<var>, e.g.,CC.
The following environment variables (and their variants) affect how this crate is built:
LMSENSORS_STATICLMSENSORS_PATHLMSENSORS_INCLUDE_DIRLMSENSORS_LIB_DIRSYSROOTCCCFLAGS
§Dynamic or static linking
This crate links to libsensors dynamically if possible, except when targeting
platforms based on the musl C library.
This behavior can be changed either by setting the environment variable
LMSENSORS_STATIC to 1, or by enabling the crate feature static.
If both are defined, then the value of LMSENSORS_STATIC takes precedence.
Setting LMSENSORS_STATIC to 0 mandates dynamic linking.
§Finding lm-sensors library and headers
By default, this crate finds lm-sensors headers and library based on the default target C compiler.
This behavior can be changed by:
- Either defining the environment variable
LMSENSORS_PATHto the path of a directory containing the sub-directoriesincludeandlibwhere the headers and library are installed. - Or by defining one or both of the environment variables
LMSENSORS_INCLUDE_DIRandLMSENSORS_LIB_DIRto paths to the directories where headers and library are present. IfLMSENSORS_PATHis also defined, thenLMSENSORS_INCLUDE_DIRandLMSENSORS_LIB_DIRtake precedence.
§Depending on this crate
This crate provides the following variables to other crates that depend on it:
DEP_LMSENSORS_INCLUDE: Path of the directory where library C header files reside.DEP_LMSENSORS_LIB: Path of the directory where the library binary resides.
§Documentation-only build mode
The documentation-only build mode allows building documentation even if
libsensors and its headers are unavailable.
To build in this mode, set the environment variable DOCS_RS to 1:
$ env DOCS_RS=1 cargo doc --openThe generated documentation is based on libsensors version 3.6.0.
⚠️ The generated crate might be unusable in this mode.
§Versioning
This project adheres to Semantic Versioning.
The CHANGELOG.md file details notable changes over time.
Modules§
Structs§
Constants§
- SENSORS_
API_ VERSION - SENSORS_
BUS_ NR_ ANY - SENSORS_
BUS_ NR_ IGNORE - SENSORS_
BUS_ TYPE_ ACPI - SENSORS_
BUS_ TYPE_ ANY - SENSORS_
BUS_ TYPE_ HID - SENSORS_
BUS_ TYPE_ I2C - SENSORS_
BUS_ TYPE_ ISA - SENSORS_
BUS_ TYPE_ MDIO - SENSORS_
BUS_ TYPE_ PCI - SENSORS_
BUS_ TYPE_ SCSI - SENSORS_
BUS_ TYPE_ SPI - SENSORS_
BUS_ TYPE_ VIRTUAL - SENSORS_
CHIP_ NAME_ ADDR_ ANY - SENSORS_
COMPUTE_ MAPPING - SENSORS_
ERR_ ACCESS_ R - SENSORS_
ERR_ ACCESS_ W - SENSORS_
ERR_ BUS_ NAME - SENSORS_
ERR_ CHIP_ NAME - SENSORS_
ERR_ DIV_ ZERO - SENSORS_
ERR_ IO - SENSORS_
ERR_ KERNEL - SENSORS_
ERR_ NO_ ENTRY - SENSORS_
ERR_ PARSE - SENSORS_
ERR_ RECURSION - SENSORS_
ERR_ WILDCARDS - SENSORS_
MODE_ R - SENSORS_
MODE_ W
Statics§
Functions§
- sensors_
cleanup ⚠ - sensors_
do_ ⚠chip_ sets - sensors_
free_ ⚠chip_ name - sensors_
get_ ⚠adapter_ name - sensors_
get_ ⚠all_ subfeatures - sensors_
get_ ⚠detected_ chips - sensors_
get_ ⚠features - sensors_
get_ ⚠label - sensors_
get_ ⚠subfeature - sensors_
get_ ⚠value - sensors_
init ⚠ - sensors_
parse_ ⚠chip_ name - sensors_
set_ ⚠value - sensors_
snprintf_ ⚠chip_ name - sensors_
strerror ⚠