[][src]Crate rvk

Overview

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

It consists of:

  • api module, which works with the API;
  • error module, which handles errors that may occur during an API call;
  • methods module, which contains API methods;
  • objects module, which contains API objects,

Example

use rvk::{methods::users, objects::user::User, APIClient, Params};

#[tokio::main]
async 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".into(), "1".into());

    let res = users::get::<Vec<User>>(&api, params).await;

    match res {
        Ok(users) => {
            let user: &User = &users[0];

            println!(
                "User #{} is {} {}.",
                user.id, user.first_name, user.last_name
            );
        }
        Err(e) => println!("{}", e),
    };
}

Re-exports

pub use crate::api::APIClient;
pub use crate::api::Params;

Modules

api

Works with the API

error

Represents errors that can happen during a method call.

methods

Contains all of the API methods in the respective submodules.

objects

Represents various objects that are returned as JSON by the API.

Constants

API_VERSION

Defines the version of VK API that is used.