| Crates.io | rainmeter-sys |
| lib.rs | rainmeter-sys |
| version | 0.1.0 |
| created_at | 2025-11-04 06:32:00.725847+00 |
| updated_at | 2025-11-04 06:32:00.725847+00 |
| description | Low-Level Rainmeter FFI Bindings |
| homepage | https://github.com/KitsuneDev/rainmeter-rs |
| repository | https://github.com/KitsuneDev/rainmeter-rs |
| max_upload_size | |
| id | 1915841 |
| size | 219,506 |
Low-level, unsafe Rust FFI bindings to the Rainmeter C/C++ plugin API. This crate is generated with bindgen at build time and links against the official Rainmeter import library bundled in this repository.
If you want to write Rainmeter plugins in idiomatic, safe Rust, you most likely want the high-level wrapper crate instead: rainmeter (../rainmeter-rs) — see its README and docs: https://docs.rs/crate/rainmeter/latest
extern "C" bindings to the functions and types from Rainmeter's C++ API headers (via bindgen).Rainmeter.lib) for your target architecture.unsafe and manage ABI details yourself.x86_64-pc-windows-msvc (x64) and i686-pc-windows-msvc (x86) targets are intended to work.native/sdk.native/wrapper.h) sets up UNICODE/_UNICODE, defines LIBRARY_EXPORTS, and includes Windows.h and sdk/API/RainmeterAPI.h.build.rs runs bindgen against that wrapper and writes Rust bindings to $OUT_DIR/bindings.rs, which is then included by src/lib.rs.cargo:rustc-link-search for native/sdk/API/{x64|x86} and cargo:rustc-link-lib=dylib=Rainmeter so your plugin links to the Rainmeter host at runtime.Repo layout (selected):
rainmeter-sys/src/lib.rs — includes the generated bindingsrainmeter-sys/build.rs — bindgen + link directivesrainmeter-sys/native/sdk — vendored Rainmeter SDK (headers + .lib files)rainmeter-sys/native/wrapper.h — bindgen entry headerBecause the bindings are generated at build time, you need a C/C++ toolchain and libclang available.
rustup toolchain install stable-x86_64-pc-windows-msvc). For 32-bit builds also install i686-pc-windows-msvc.bindgen cannot find libclang, set the LIBCLANG_PATH environment variable to the folder that contains libclang.dll.Example for PowerShell (adjust version/path):
$env:LIBCLANG_PATH = "C:\\Program Files\\LLVM\\bin"
Add to your Cargo.toml if using directly (advanced/FFI-only use cases):
[dependencies]
rainmeter-sys = { version = "0.1", package = "rainmeter-sys" }
Within this workspace, other crates depend on it by path.
Most users should instead depend on the safe wrapper:
[dependencies]
rainmeter = "0.1"
cargo build --release
rustup target add i686-pc-windows-msvc
cargo build --release --target i686-pc-windows-msvc
The build script chooses the correct native/sdk/API/{x64|x86} library directory based on your target triple.
The raw API mirrors the C/C++ Rainmeter API and requires unsafe. Names and signatures come directly from the Rainmeter headers. A very rough sketch (do not copy blindly):
use rainmeter_sys as sys;
unsafe fn example_logging(rm: sys::LPVOID) {
// Function names/types are generated from the C++ headers and may differ.
// Refer to the generated docs or inspect `OUT_DIR/bindings.rs` when building.
let msg = widestring::U16CString::from_str_unchecked("Hello from Rust (sys)!");
// e.g. sys::RmLog(rm, sys::LOG_NOTICE, msg.as_ptr());
}
For a practical, safe approach with traits and ergonomic helpers, use the rainmeter crate in this repo.
LIBCLANG_PATH to the directory containing libclang.dll.Rainmeter.lib:
*-pc-windows-msvc and not gnu.rainmeter): https://docs.rs/crate/rainmeter/latest