| Crates.io | lib60870-sys |
| lib.rs | lib60870-sys |
| version | 0.5.1 |
| created_at | 2025-12-07 09:37:55.418201+00 |
| updated_at | 2025-12-07 09:46:18.951426+00 |
| description | Raw FFI bindings to lib60870-C, an IEC 60870-5-101/104 protocol implementation. |
| homepage | |
| repository | https://github.com/tomas789/lib60870-sys |
| max_upload_size | |
| id | 1971357 |
| size | 441,598 |
Raw FFI bindings to lib60870-C, an IEC 60870-5-101/104 protocol implementation.
This is a -sys crate that provides low-level, unsafe bindings to the C library. For a safe, idiomatic Rust API, consider using the lib60870 crate.
| Platform | Status |
|---|---|
| Linux | ✅ Fully supported |
| macOS | ✅ Fully supported |
| Windows | ⚠️ Experimental (build works, runtime issues) |
Note: Windows support is experimental. The library compiles successfully but may have runtime issues related to DLL dependencies. Contributions to improve Windows support are welcome!
Add this to your Cargo.toml:
[dependencies]
lib60870-sys = "0.4"
# With TLS support:
lib60870-sys = { version = "0.4", features = ["tls"] }
use lib60870_sys::*;
use std::ffi::CString;
fn main() {
// Get library version
let version = unsafe { Lib60870_getLibraryVersionInfo() };
println!(
"lib60870 v{}.{}.{}",
version.major, version.minor, version.patch
);
// Create a connection
let ip = CString::new("127.0.0.1").unwrap();
let port = 2404;
let conn = unsafe { CS104_Connection_create(ip.as_ptr(), port) };
if !conn.is_null() {
println!("Connection created successfully");
// Clean up
unsafe { CS104_Connection_destroy(conn) };
println!("Connection destroyed");
} else {
println!("Failed to create connection");
}
}
Run the example:
cargo run --example version
Safety: All functions in this crate are
unsafebecause they directly call C code. Users must ensure proper memory management, null pointer handling, and correct C string formatting.
| Feature | Description |
|---|---|
tls |
Enable TLS support (downloads mbedtls 2.28) |
debug |
Enable printf debug output |
no-threads |
Disable threading (for embedded systems) |
tcp-keepalive |
Enable TCP keep-alive |
The build script (build.rs) automatically:
tls feature is enabled)All downloads are cached in target/ so subsequent builds are fast.
For docs.rs and environments without network access, this crate includes pre-generated bindings in src/bindings_pregenerated.rs. These are used automatically when building with the docsrs cfg flag.
Requirements:
cargo build
cargo build --features tls
lib60870-C is dual-licensed under GPLv3 and a commercial license. This crate inherits the GPL-3.0 license. See the lib60870 repository for commercial licensing options.