vkclient

Crates.iovkclient
lib.rsvkclient
version5.1.2
sourcesrc
created_at2022-10-01 15:49:14.913721
updated_at2024-04-12 14:43:28.702277
descriptionVk Api client implementation
homepage
repositoryhttps://github.com/Mnwa/vkclient
max_upload_size
id677880
size42,398
Mikhail Panfilov (Mnwa)

documentation

https://docs.rs/vkclient

README

VK API Client

This is a base pure rust implementation of VK API client. The client supports zstd compression and msgpack format of VK API. It's works with http2 only connections.

Supported features

  • API requests
  • Longpoll
  • Upload files

See the library documentation or VK API documentation for more.

Usage

use vkclient::VkApi;

fn main() {
    let client: VkApi = vkclient::VkApiBuilder::new(access_token).into();
    ..
}
use vkclient::{VkApi, VkApiResult, List};
use serde::{Deserialize, Serialize};

async fn get_users_info(client: &VkApi) -> VkApiResult<Vec<UsersGetResponse>> {
    client.send_request("users.get", UsersGetRequest {
        user_ids: List(vec![1,2]),
        fields: List(vec!["id", "sex"]),
   }).await
}

#[derive(Serialize)]
struct UsersGetRequest<'a> {
    user_ids: List<Vec<usize>>,
    fields: List<Vec<&'a str>>,
}

#[derive(Deserialize)]
struct UsersGetResponse {
    id: i64,
    first_name: String,
    last_name: String,
    sex: u8,
}
Commit count: 62

cargo fmt