https://github.com/LostQuasar/rzap
A rust library for connecting to an openshock server
https://github.com/LostQuasar/rzap
openshock rust
Last synced: 4 months ago
JSON representation
A rust library for connecting to an openshock server
- Host: GitHub
- URL: https://github.com/LostQuasar/rzap
- Owner: LostQuasar
- License: gpl-3.0
- Created: 2024-06-11T23:58:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-13T19:33:07.000Z (over 1 year ago)
- Last Synced: 2025-10-14T20:44:14.695Z (8 months ago)
- Topics: openshock, rust
- Language: Rust
- Homepage: https://crates.io/crates/rzap
- Size: 58.6 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-openshock - rzap - Rust crate to interact with OpenShock API. (Libraries / Rust)
README
# rzap
This library provides an interface to controll shocker devices via [OpenShock](http://openshock.org)'s API
NOTE: This is an un-official API iterface created by someone who has just started learning rust, no guarantees are made and contributions are greatly welcomed
```
[dependencies]
reqwest = { version = "0.11.27" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
strum_macros = "0.26.4"
strum = "0.26.2"
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
```
## Example
A simple request to retrieve the API key user's id
```rs
dotenv().ok();
let openshock_token = dotenv::var("OPENSHOCK_TOKEN").expect("missing OPENSHOCK_TOKEN");
let app_name = env!("CARGO_PKG_NAME");
let app_version = env!("CARGO_PKG_VERSION");
assert_ne!(openshock_token, "");
openshock_api = OpenShockAPIBuilder::new()
.with_app(app_name.to_string(), Some(app_version.to_string()))
.with_default_api_token(openshock_token)
.build()
.unwrap();
println!(openshock_api.get_user_info(None).await.unwrap().id);
```