rvk
A crate for accessing VK API in Rust (synchronously).
Add the dependency to your Cargo.toml
file:
toml
[dependencies]
rvk = "0.4"
Also, add this line to your crate:
rust
extern crate rvk;
Now you can take a look at this crate's API documentation to learn more about the available functions.
To use this example, you will also need the following crates:
toml
[dependencies]
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
```rust extern crate rvk; use rvk::{methods::*, APIClient, Params};
extern crate serde;
extern crate serdederive; extern crate serdejson; use serdejson::fromvalue;
struct User { id: u64, firstname: String, lastname: String, }
fn main() { let api = APIClient::new("youraccesstoken"); // Create an API Client
let mut params = Params::new(); // Create a HashMap to store parameters
params.insert("user_ids", "1");
let res = users::get(&api, params);
match res {
Ok(v) => { // v is `serde_json::Value`
let users: Vec<User> = from_value(v).unwrap();
let user = &users[0];
println!(
"User #{} is {} {}.",
user.id, user.first_name, user.last_name
);
}
Err(e) => println!("{}", e),
};
} ```