Crate vkclient

source ·
Expand description

§Base VK API client realisation.

This client supports zstd compression and msgpack format of VK API. It’s works with http2 only connections.

§VK API Clients list:

§Usage

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

async {
    let users = get_users_info(&client).await.unwrap();
}

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,
}

§Features

  • compression_zstd - enabled by default. Adds zstd compression support;
  • compression_gzip - enabled by default. Adds gzip compression support;
  • encode_json - enabled by default. Adds json encoding support;
  • encode_msgpack - enabled by default. Adds msgpack encoding support;
  • uploader - enabled by default. Adds file uploads support.
  • longpoll - enabled by default. Adds longpoll support.
  • longpoll_stream - enabled by default. Adds converter long poll queries to futures stream.

Modules§

Structs§

  • Vk API List helper Serialize any iterable struct with ToString items to string separated by comma. Example:
  • Major and minor versions of VK API
  • Base VK API client realisation.
  • API Client builder struct. Use VkApi::from or into to make VkApi struct.
  • VK Backend business logic errors. More info about codes.

Enums§

  • Vk Api errors. VkApiError::Vk - is an error of buisness logic, like expired token or incorrect request params Other errors is about things around your request, like a serialization/deserialization or network errors.

Traits§

Type Aliases§