pub struct WebhookClientBuilder { /* private fields */ }Expand description
Builder for WebhookClient with configurable timeout settings.
Use this instead of WebhookClient::new when you need to control connect
or overall request timeouts rather than accepting the 30-second default.
§Example
use discord_hook::WebhookClientBuilder;
use std::time::Duration;
let client = WebhookClientBuilder::new("https://discord.com/api/webhooks/ID/TOKEN")
.connect_timeout(Duration::from_secs(5))
.request_timeout(Duration::from_secs(15))
.build()?;Implementations§
Source§impl WebhookClientBuilder
impl WebhookClientBuilder
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Start building a client for the given Discord webhook URL.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set the maximum time allowed to establish a TCP connection.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
Set the maximum time allowed for a complete request/response cycle.
Defaults to 30 seconds.
Sourcepub fn build(self) -> Result<WebhookClient, WebhookError>
pub fn build(self) -> Result<WebhookClient, WebhookError>
Validate the URL and build the WebhookClient.
§Errors
WebhookError::InvalidUrl— URL is not a valid Discord webhook URL.WebhookError::Http— underlying HTTP client could not be constructed (e.g. TLS backend unavailable).
Auto Trait Implementations§
impl Freeze for WebhookClientBuilder
impl RefUnwindSafe for WebhookClientBuilder
impl Send for WebhookClientBuilder
impl Sync for WebhookClientBuilder
impl Unpin for WebhookClientBuilder
impl UnsafeUnpin for WebhookClientBuilder
impl UnwindSafe for WebhookClientBuilder
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