Struct vkclient::LongPollClient
source · pub struct LongPollClient { /* private fields */ }Expand description
Client for long poll subscriptions
Use it to subscribe on some VK events, like the UserLong Poll API or the Bots Long Poll API.
Usage:
use vkclient::VkApi;
let client: VkApi = vkclient::VkApiBuilder::new(access_token).into();
let longpoll_client = client.longpoll();use vkclient::LongPollClient;
let longpoll_client = LongPollClient::default();Implementations
sourceimpl LongPollClient
impl LongPollClient
sourcepub fn subscribe<T: Serialize + Clone, I: DeserializeOwned>(
&self,
request: LongPollRequest<T>
) -> impl Stream<Item = Result<I, VkApiError>>
pub fn subscribe<T: Serialize + Clone, I: DeserializeOwned>(
&self,
request: LongPollRequest<T>
) -> impl Stream<Item = Result<I, VkApiError>>
Returns an events stream from long poll server.
Usage
use vkclient::{LongPollClient, LongPollRequest};
let longpoll_client = LongPollClient::default();
longpoll_client.subscribe(LongPollRequest {
key,
server,
ts,
wait: 25,
additional_params: (),
})
.take(1)
.for_each(|r| async move { println!("{:?}", r) });sourcepub async fn subscribe_once<T: Serialize, I: DeserializeOwned>(
&self,
request: LongPollRequest<T>
) -> Result<LongPollSuccess<I>, VkApiError>
pub async fn subscribe_once<T: Serialize, I: DeserializeOwned>(
&self,
request: LongPollRequest<T>
) -> Result<LongPollSuccess<I>, VkApiError>
Returns first events chunk from long poll server.
Usage
use vkclient::{LongPollClient, LongPollRequest};
let longpoll_client = LongPollClient::default();
longpoll_client.subscribe_once(LongPollRequest {
key,
server,
ts,
wait: 25,
additional_params: (),
});Trait Implementations
sourceimpl Clone for LongPollClient
impl Clone for LongPollClient
sourcefn clone(&self) -> LongPollClient
fn clone(&self) -> LongPollClient
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresourceimpl Debug for LongPollClient
impl Debug for LongPollClient
sourceimpl Default for LongPollClient
impl Default for LongPollClient
sourceimpl From<Client<HttpsConnector<HttpConnector<GaiResolver>>, Body>> for LongPollClient
impl From<Client<HttpsConnector<HttpConnector<GaiResolver>>, Body>> for LongPollClient
sourcefn from(client: Client<HttpsConnector<HttpConnector>, Body>) -> Self
fn from(client: Client<HttpsConnector<HttpConnector>, Body>) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for LongPollClient
impl Send for LongPollClient
impl Sync for LongPollClient
impl Unpin for LongPollClient
impl !UnwindSafe for LongPollClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more