Struct telegram_bot_ars::Api

source ·
pub struct Api(_);
Expand description

Main type for sending requests to the Telegram bot API.

Implementations§

Create a new Api instance.

Example

Using default connector.

use telegram_bot_ars::Api;

let api = Api::new(telegram_token);

Create a new Api instance wtih custom connector.

Create a stream which produces updates from the Telegram server.

Examples
use futures::StreamExt;


let mut stream = api.stream();
let update = stream.next().await;
    println!("{:?}", update);

Send a request to the Telegram server and do not wait for a response.

Examples
let chat = ChatId::new(61031);
api.spawn(chat.text("Message"));

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
let result = api.send_timeout(GetMe, Duration::from_secs(2)).await;
println!("{:?}", result);

Send a request to the Telegram server and wait for a response.

Examples
let result = api.send(GetMe).await;
println!("{:?}", result);

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more