pub struct WebhookService { /* private fields */ }Expand description
A generic webhook service that can send messages to any service.
Implementations§
Source§impl WebhookService
impl WebhookService
Sourcepub fn new(
name: String,
url: String,
client: HttpClient,
service_info: Arc<ServiceInfo>,
sender: BoxedWebhookSender,
) -> Self
pub fn new( name: String, url: String, client: HttpClient, service_info: Arc<ServiceInfo>, sender: BoxedWebhookSender, ) -> Self
Create a new webhook service with full configuration.
Sourcepub fn with_sender(sender: BoxedWebhookSender) -> Self
pub fn with_sender(sender: BoxedWebhookSender) -> Self
Create a new webhook service with just a sender (minimal constructor).
§Example
use hookburn_core::{WebhookService, BoxedWebhookSender};
let sender: BoxedWebhookSender = Box::new(my_sender);
let service = WebhookService::with_sender(sender);Sourcepub fn with_default_username(self, username: impl Into<String>) -> Self
pub fn with_default_username(self, username: impl Into<String>) -> Self
Set a default username for all messages.
Sourcepub fn with_default_avatar(self, avatar_url: impl Into<String>) -> Self
pub fn with_default_avatar(self, avatar_url: impl Into<String>) -> Self
Set a default avatar URL for all messages.
Sourcepub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
pub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
Set the retry policy for this service.
Sourcepub fn with_service_info(self, info: Arc<ServiceInfo>) -> Self
pub fn with_service_info(self, info: Arc<ServiceInfo>) -> Self
Set the service info.
Sourcepub async fn send_generic(
&self,
message: &GenericMessage,
) -> Result<(), CoreError>
pub async fn send_generic( &self, message: &GenericMessage, ) -> Result<(), CoreError>
Send a generic message to the webhook service.
§Errors
Returns CoreError if the message fails to send.
Sourcepub async fn send_generic_with_retry(
&self,
message: &GenericMessage,
) -> Result<(), CoreError>
pub async fn send_generic_with_retry( &self, message: &GenericMessage, ) -> Result<(), CoreError>
Sourcepub const fn info(&self) -> &Arc<ServiceInfo> ⓘ
pub const fn info(&self) -> &Arc<ServiceInfo> ⓘ
Get the service info.
Sourcepub const fn client(&self) -> &HttpClient
pub const fn client(&self) -> &HttpClient
Get the underlying HTTP client.
Trait Implementations§
Source§impl Clone for WebhookService
impl Clone for WebhookService
Source§impl WebhookSender for WebhookService
impl WebhookSender for WebhookService
Source§type Message = GenericMessage
type Message = GenericMessage
The type of message this sender accepts (e.g.,
WebhookMessage for Discord).Source§type Error = CoreError
type Error = CoreError
The error type returned when sending fails (e.g.,
WebhookError for Discord).Source§fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 Self::Message,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 Self::Message,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a single message to the configured webhook endpoint. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for WebhookService
impl !UnwindSafe for WebhookService
impl Freeze for WebhookService
impl Send for WebhookService
impl Sync for WebhookService
impl Unpin for WebhookService
impl UnsafeUnpin for WebhookService
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