[−][src]Struct telegram_bot_async::Api
Main type for sending requests to the Telegram bot API.
Methods
impl<C: Connector> Api<C>
[src]
pub fn new_default(token: String) -> Result<DefaultApi, Error>
[src]
Start construction of the Api
instance.
Examples
Using default connector.
use telegram_bot_fork::DefaultApi; let api = DefaultApi::new_default(telegram_token.to_string()).unwrap();
pub fn with_connector(token: String, connector: C) -> Api<C>
[src]
Creates new API using custom connector.
use telegram_bot_fork::{connector::hyper, Api}; let api = Api::with_connector(telegram_token.to_string(), hyper::default_connector().unwrap());
pub fn set_url<T: AsRef<str>>(&mut self, url: T) -> &mut Self
[src]
Sets base telegram API server URL.
pub fn into_stream(self) -> UpdatesStream<C>
[src]
Create a stream which produces updates from the Telegram server.
Examples
#[for_await] for update in stream.updates() { println!("{:?}", update); } Ok(())
pub async fn send_timeout<'_, Req: Request>(
&'_ self,
request: Req,
duration: Duration
) -> Result<<Req::Response as ResponseType>::Type, Error>
[src]
&'_ self,
request: Req,
duration: Duration
) -> Result<<Req::Response as ResponseType>::Type, Error>
Send a request to the Telegram server and wait for a response, timing out after duration
.
Future will resolve to None
if timeout fired.
Examples
use std::time::Duration; let resp = api.send_timeout(GetMe, Duration::from_secs(5)).await?; Ok(())
pub async fn send<'_, Req: Request>(
&'_ self,
request: Req
) -> Result<<Req::Response as ResponseType>::Type, Error>
[src]
&'_ self,
request: Req
) -> Result<<Req::Response as ResponseType>::Type, Error>
Send a request to the Telegram server and wait for a response.
Examples
let resp = api.send(GetMe).await?; Ok(())
Trait Implementations
Auto Trait Implementations
impl<C> RefUnwindSafe for Api<C> where
C: RefUnwindSafe,
C: RefUnwindSafe,
impl<C> Send for Api<C>
impl<C> Sync for Api<C>
impl<C> Unpin for Api<C> where
C: Unpin,
C: Unpin,
impl<C> UnwindSafe for Api<C> where
C: UnwindSafe,
C: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,