[][src]Struct telexide::api::APIClient

pub struct APIClient { /* fields omitted */ }

A default implementation of the API trait.

It requires your bot token in order to interact with the telegram API and also allows you to configure your own hyper::Client for it to use.

Using the default APIClient is as easy as:

use telexide::api::{APIClient, API, types::SendMessage};

    let message = SendMessage::new(chat_id, "hi!");

    let client = APIClient::new_default(token);
    client.send_message(message).await;

In most cases you would want to get updates though and the Client is best suited for that, as it allows for easier handling of those updates

Implementations

impl APIClient[src]

pub fn new<T: ToString>(
    hyper_client: Option<Client<HttpsConnector<HttpConnector>>>,
    token: T
) -> Self
[src]

Creates a new APIClient with the provided token and hyper client (if it is Some).

pub fn new_default<T: ToString>(token: T) -> Self[src]

Creates a new APIClient with the provided token and the default hyper client.

pub async fn request<D: ?Sized, '_, '_>(
    &'_ self,
    endpoint: APIEndpoint,
    data: Option<&'_ D>
) -> Result<Response> where
    D: Serialize
[src]

Sends a request to the provided APIEndpoint with the data provided (does not support files)

pub fn get_hyper(&self) -> &Client<HttpsConnector<HttpConnector>>[src]

gets a reference to the underlying hyper client, for example so you can make custom api requests

Trait Implementations

impl API for APIClient[src]

Auto Trait Implementations

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> Instrument for T[src]

impl<T> Instrument 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.

impl<T> UnsafeAny for T where
    T: Any