rzap

Crates.iorzap
lib.rsrzap
version0.2.1
sourcesrc
created_at2024-06-14 00:07:53.111137
updated_at2024-10-13 19:15:31.333053
descriptionInterface with OpenShock via Rust
homepagehttps://github.com/LostQuasar/rzap
repositoryhttps://github.com/LostQuasar/rzap
max_upload_size
id1271523
size53,145
LostQuasar (LostQuasar)

documentation

https://docs.rs/rzap/latest/rzap/

README

rzap

This library provides an interface to controll shocker devices via OpenShock'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

    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);
Commit count: 31

cargo fmt