Skip to main content

ApplicationBuilder

Struct ApplicationBuilder 

Source
pub struct ApplicationBuilder<State = NoToken> { /* private fields */ }
Expand description

Typestate builder for constructing an Application.

The builder enforces at compile time that a bot token is set before build can be called, using the NoToken / HasToken marker types.

Implementations§

Source§

impl ApplicationBuilder

Source

pub fn new() -> ApplicationBuilder

Create a new builder with no token and default settings.

Source

pub fn token(self, token: impl Into<String>) -> ApplicationBuilder<HasToken>

Set the bot token. Transitions the builder to the HasToken state.

Source§

impl<S> ApplicationBuilder<S>

Source

pub fn request(self, request: Arc<dyn BaseRequest>) -> ApplicationBuilder<S>

Set a custom HTTP request backend for the bot.

Source

pub fn base_url(self, url: impl Into<String>) -> ApplicationBuilder<S>

Override the base URL for Telegram Bot API requests.

Source

pub fn base_file_url(self, url: impl Into<String>) -> ApplicationBuilder<S>

Override the base URL for downloading files from Telegram.

Source

pub fn defaults(self, defaults: Defaults) -> ApplicationBuilder<S>

Set default values (e.g. parse_mode) applied to every API call.

Source

pub fn arbitrary_callback_data(self, maxsize: usize) -> ApplicationBuilder<S>

Enable the arbitrary callback data cache with the given maximum size.

Source

pub fn rate_limiter(self, _rl: ()) -> ApplicationBuilder<S>

Sets the rate-limiter placeholder (feature disabled).

Source

pub fn context_types(self, ct: ContextTypes) -> ApplicationBuilder<S>

Set custom context types for the application.

Source

pub fn concurrent_updates(self, n: usize) -> ApplicationBuilder<S>

Set the maximum number of concurrent update processing tasks. Minimum is 1.

Source

pub fn post_init( self, hook: Arc<dyn Fn(Arc<Application>) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>, ) -> ApplicationBuilder<S>

Register a hook to run after the application has been initialized.

Source

pub fn post_stop( self, hook: Arc<dyn Fn(Arc<Application>) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>, ) -> ApplicationBuilder<S>

Register a hook to run after the application has stopped.

Source

pub fn post_shutdown( self, hook: Arc<dyn Fn(Arc<Application>) -> Pin<Box<dyn Future<Output = ()> + Send>> + Sync + Send>, ) -> ApplicationBuilder<S>

Register a hook to run after the application has been fully shut down.

Source§

impl ApplicationBuilder<HasToken>

Source

pub fn build(self) -> Arc<Application>

Consume the builder and construct the Application.

Trait Implementations§

Source§

impl<S> Debug for ApplicationBuilder<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for ApplicationBuilder

Source§

fn default() -> ApplicationBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<State> Freeze for ApplicationBuilder<State>

§

impl<State = NoToken> !RefUnwindSafe for ApplicationBuilder<State>

§

impl<State> Send for ApplicationBuilder<State>
where State: Send,

§

impl<State> Sync for ApplicationBuilder<State>
where State: Sync,

§

impl<State> Unpin for ApplicationBuilder<State>
where State: Unpin,

§

impl<State> UnsafeUnpin for ApplicationBuilder<State>

§

impl<State = NoToken> !UnwindSafe for ApplicationBuilder<State>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more