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§
- List
- Vk API List helper
Serialize any iterable struct with
ToString
items to string separated by comma. Example: - Version
- Major and minor versions of VK API
- VkApi
- Base VK API client realisation.
- VkApi
Builder - API Client builder struct.
Use
VkApi::from
orinto
to makeVkApi
struct. - 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 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§
- VkApi
Wrapper - API method description
Type Aliases§
- VkApi
Result - Shorthand for
Result<T, VkApiError>