Crates.io | sysfs |
lib.rs | sysfs |
version | 0.0.2 |
source | src |
created_at | 2024-07-15 07:28:18.247789 |
updated_at | 2024-07-17 05:47:32.172356 |
description | Proc-macro helpers for writing large swaths of ergonomic wrappers around Linux sysfs attributes. |
homepage | https://github.com/spikespaz/sysfs-rs |
repository | https://github.com/spikespaz/sysfs-rs |
max_upload_size | |
id | 1303547 |
size | 57,643 |
[!IMPORTANT] Please note that this crate is very incomplete, and will not be considered stable for quite some time. The public API is subject to change, drastically. As more
sysfs
attributes are wrapped and documented, it may be desireable to change the organizational structure to offer a more homogeneous and consistent developer experience.
This crate embodies three core goals:
Provide safe functions and types for (eventually) all of Linux's sysfs
attributes in a well-organized hierarchy.
Document each sysfs
attribute, as well as the types of data being read from and written to these attributes. Information about sysfs
is spread around everywhere, from comments in source code to discussion threads in mailing lists. This crate aims to aggregate that knowledge, and make it easily digestible.
Provide attribute macro helpers and transformation functions to generate accessors for any given sysfs
attribute. Since sysfs
is quite large and individual attributes are difficult to discover and get right, this crate's internal macros are exported for other developers, so that they may define attributes and modules which are missing in this crate.
See the Wikipedia page and the Kernel documentation for more information about Linux's sysfs
.
First, there are some modules defined for sysfs
directories whose attributes have already been wrapped. Browse the documentation in the crate's sysfs::api
module to see if it has what you need. There are getter functions, for example sysfs::api::psu::power_supply::capacity
, which reads the charge level of the battery as an f32
percentage value (0.00 .. 1.00
). Then there are setters, which serialize and write typed data to a sysfs
attribute file, such as sysfs::api::psu::power_supply::set_charge_behavior
.
Second, if there is no wrapper already defined in this crate's sysfs::api
module, feel free to implement your own! See the documentation on items in sysfs::lib
and the source code of existing modules (such as sysfs::api::cpu
) for an idea of how to get started. Also, contributions to the api
module are very much welcome and appreciated!