pub struct ClientConfig {
pub token: String,
pub api_base_url: String,
pub timeout: Duration,
pub max_retries: u8,
}Expand description
Configuration for BotClient.
Use the builder methods to customise behaviour, then pass the config to
BotClient::new.
§Example
ⓘ
use std::time::Duration;
let config = ClientConfig::new("123456:ABC...")?
.api_base_url("http://localhost:8081") // local Bot API server
.timeout(Duration::from_secs(60))
.max_retries(5);Fields§
§token: StringBot token used to authenticate with the Telegram API.
api_base_url: StringBase URL of the Bot API server (default: https://api.telegram.org).
timeout: DurationPer-request HTTP timeout.
max_retries: u8Maximum number of automatic retries on flood control responses.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(token: impl Into<String>) -> Result<Self>
pub fn new(token: impl Into<String>) -> Result<Self>
Creates a new ClientConfig with the given bot token and default settings.
Sourcepub fn api_base_url(self, url: impl Into<String>) -> Self
pub fn api_base_url(self, url: impl Into<String>) -> Self
Sets a custom base URL for API requests, e.g. for a local Bot API server.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets a custom timeout for API requests (default 30 seconds).
Sourcepub fn max_retries(self, n: u8) -> Self
pub fn max_retries(self, n: u8) -> Self
Sets the maximum number of retries on HTTP 429 (flood control) errors (default 3).
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§fn clone(&self) -> ClientConfig
fn clone(&self) -> ClientConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ClientConfig
impl RefUnwindSafe for ClientConfig
impl Send for ClientConfig
impl Sync for ClientConfig
impl Unpin for ClientConfig
impl UnsafeUnpin for ClientConfig
impl UnwindSafe for ClientConfig
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