Crate rvk [] [src]

Overview

This is a crate for accessing VK API (synchronously).

All of the API methods are located in the methods module of this crate (in the corresponding submodules).

Example

extern crate rvk;
use rvk::{APIClient, Params, methods::*};

extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
use serde_json::from_value;

#[derive(Deserialize)]
struct User {
    id: u64,
    first_name: String,
    last_name: String,
}

fn main() {
    let mut api = APIClient::new("your_access_token"); // 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),
    };
}

Re-exports

pub use api::APIClient;

Modules

api

Works with the API

error

All errors that can happen during a method call

methods

Contains all of the API methods in the respective submodules.

Type Definitions

Params

A HashMap which contains method parameters