vaegram 0.3.0

Telegram MTProto client library for users and bots
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::future::Future;

use crate::Client;
use crate::errors::Result;
use crate::handlers::{HandlerRef, UpdateKind, callback};

impl Client {
    /// Runs as `run` returns, after the running handlers finished and the update state was handed back, so it can
    /// still send. It also runs when a lost connection ended `run`, and then its requests fail. Only a `run` that
    /// got as far as `on_start` gets it. An `Err` goes to `on_error`. Registering again replaces it.
    pub fn on_stop<F, Fut, T>(&self, f: F) -> HandlerRef<'_>
    where
        F: Fn(Client) -> Fut + Send + Sync + 'static,
        Fut: Future<Output = Result<T>> + Send + 'static,
    {
        self.register(UpdateKind::Stop, |r, id| r.hooks.set(UpdateKind::Stop, id, callback(f)))
    }
}