[][src]Struct vkapi::vk::VK

pub struct VK<'a> { /* fields omitted */ }

VK structure, used for call api method, use longpoll api and etc

Methods

impl<'a> VK<'a>[src]

pub fn new(api_version: &'a str, language: &'a str) -> Self[src]

Create new instance of VK struct

Arguments:

  • api_version - pick up one here
  • language - here

pub fn set_access_token(&mut self, token: String)[src]

Set access token

pub fn get_access_token(&self) -> &String[src]

Get a reference to token

pub async fn start_longpoll<'_>(
    &'_ self,
    group_id: u32,
    wait: u16,
    callback: Box<dyn Fn(&JsonValue)>
)
[src]

This methond starts to longpolling, It's sad, but as for now there're ways to stop it (but I'm gonna make it)

Arguments:

  • group_id - your group ID
  • wait - Maximal time to waiting, max value is 90
  • callback - closure which have 1 argument: event

pub async fn upload<'_>(
    &'_ self,
    file: File,
    params: Params
) -> Result<JsonValue, String>
[src]

Use if you want to upload any file

Arguments:

file - is File struct

Return:

this method returns JsonValue like this: [{"id":457239436,"album_id":-64,"owner_id":-142102660,"user_id":100,"sizes":[{"type":"s","url":"https://sun9-64.userapi.com/c857724/v857724964/1cd30a/OkprPbgIA4M.jpg","width":75,"height":42},{"type":"m","url":"https://sun9-11.userapi.com/c857724/v857724964/1cd30b/zf7PALt9LiQ.jpg","width":130,"height":73},{"type":"x","url":"https://sun9-42.userapi.com/c857724/v857724964/1cd30c/QkU_GWrWrtg.jpg",":"o","url":"https://sun9-55.userapi.com/c857724/v857724964/1cd30f/VuJoCsfzNhQ.jpg","width":130,"height":87},{"type":"p","url":"https://sun9-7.userapi.com/c857724/v857724964/1cd310/03M7NFSwldw.jpg","width":200,"height":133},{"type":"q","url":"https://sun9-27.userapi.com/c857724/v857724964/1cd311/E-l93bSWpSk.jpg","width":320,"height":213},{"type":"r","url":"https://sun9-61.userapi.com/c857724/v857724964/1cd312/0aqWUY6M9jE.jpg","width":510,"height":340}],"text":"","date":1587293486,"access_key":"cb0b2221048b3d8021"}] More details about return here

pub async fn request<'_, '_, '_>(
    &'_ self,
    method: &'_ str,
    params: &'_ mut Params
) -> Result<JsonValue, String>
[src]

Used for request API

Arguments:

  • method - all methods are listed here
  • params - params to call API. use Params::new() and then params.add()

pub async fn request_public<'_, '_, '_, '_, '_>(
    method: &'_ str,
    params: &'_ mut Params,
    access_token: &'_ Option<String>,
    api_version: &'_ str,
    language: &'_ str
) -> Result<JsonValue, String>
[src]

** I'm not recommend use it ** You can use request but without constructing VK instance

pub async fn direct_auth<'_, '_, '_>(
    &'_ mut self,
    login: &'_ str,
    password: &'_ str
) -> Result<(), JsonValue>
[src]

Used for direct auth

  • login - email or phone number
  • password - Hm..what it's supposed to be

Auto Trait Implementations

impl<'a> RefUnwindSafe for VK<'a>

impl<'a> Send for VK<'a>

impl<'a> Sync for VK<'a>

impl<'a> Unpin for VK<'a>

impl<'a> UnwindSafe for VK<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.