pub struct ReqwestTelegram { /* private fields */ }Expand description
A Telegram which really talks to the Bot API over HTTP.
Implementations§
Source§impl ReqwestTelegram
impl ReqwestTelegram
Sourcepub fn new(
settings: TelegramSettings,
client: Option<Client>,
) -> Result<Self, TelegramError>
pub fn new( settings: TelegramSettings, client: Option<Client>, ) -> Result<Self, TelegramError>
Creates a notifier and spawns its background delivery worker.
If client is None, an HTTP client is built from the timeouts in
settings. Passing an existing client lets the notifier share the
application’s connection pool.
§Errors
Returns TelegramError::Http if a client must be built and cannot be.
§Panics
Panics if called outside a Tokio runtime, because the delivery worker is spawned during construction.
Sourcepub async fn flush(&self, timeout: Duration) -> bool
pub async fn flush(&self, timeout: Duration) -> bool
Waits for every queued message to be delivered, up to timeout.
Call this during shutdown. Without it, whatever is still queued when the process exits is lost — including, typically, the notification about whatever caused the shutdown.
Returns true if the queue drained in time.
Trait Implementations§
Source§impl Debug for ReqwestTelegram
impl Debug for ReqwestTelegram
Auto Trait Implementations§
impl !RefUnwindSafe for ReqwestTelegram
impl !UnwindSafe for ReqwestTelegram
impl Freeze for ReqwestTelegram
impl Send for ReqwestTelegram
impl Sync for ReqwestTelegram
impl Unpin for ReqwestTelegram
impl UnsafeUnpin for ReqwestTelegram
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more