Expand description
§Base VK API client realisation.
This client supports zstd compression and msgpack format of VK API. It works with http2-only connections.
§VK API Clients list:
§Usage
use vkclient::{List, VkApi, VkApiResult};
use serde::{Serialize, Deserialize};
fn demo() {
let access_token = String::new();
let client: VkApi = vkclient::VkApiBuilder::new(access_token).into();
async {
let users = get_users_info(&client).await.unwrap();
let _ = users;
};
}
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§
- List
- Vk API List helper
Serialize any iterable struct with
ToStringitems to string separated by comma. Example: - Version
- Major and minor versions of VK API
- VkApi
- Base VK API client realization.
- VkApi
Builder - API Client builder struct.
Use
VkApi::fromorintoto makeVkApistruct. - VkError
- VK Backend business logic errors. More info about codes.
Enums§
- Compression
- Encoding
- Response
Deserialize - VkApi
Error - Vk Api errors.
VkApiError::Vk- is an error of business logic, like expired token or incorrect request params Other errors are about things around your request, like a serialization/deserialization or network errors.
Traits§
- VkApi
Wrapper - API method description
Type Aliases§
- VkApi
Result - Shorthand for
Result<T, VkApiError>