pub struct WebhookDispatcher { /* private fields */ }Implementations§
Source§impl WebhookDispatcher
impl WebhookDispatcher
pub fn builder() -> WebhookDispatcherBuilder
Sourcepub fn register_rule<T: 'static>(
&mut self,
rule: impl Fn(&T) -> &'static str + Send + Sync + 'static,
)
pub fn register_rule<T: 'static>( &mut self, rule: impl Fn(&T) -> &'static str + Send + Sync + 'static, )
Register a matcher rule for type T. When send is called with a T,
this closure decides which template name to use.
Sourcepub fn register_template(
&self,
name: &str,
template: &str,
) -> Result<(), WebhookError>
pub fn register_template( &self, name: &str, template: &str, ) -> Result<(), WebhookError>
Register a new template at runtime.
Sourcepub fn update_template(
&self,
name: &str,
template: &str,
) -> Result<(), WebhookError>
pub fn update_template( &self, name: &str, template: &str, ) -> Result<(), WebhookError>
Overwrite an existing template at runtime without restarting the dispatcher.
Sourcepub fn remove_template(&self, name: &str)
pub fn remove_template(&self, name: &str)
Remove a template at runtime.
Sourcepub async fn send<T: Serialize + 'static>(
&self,
event: &T,
) -> Result<(), WebhookError>
pub async fn send<T: Serialize + 'static>( &self, event: &T, ) -> Result<(), WebhookError>
Send using the internal matcher to resolve the template name.
Sourcepub async fn send_with_hints<T: Serialize + 'static>(
&self,
event: &T,
hints: WithHints,
) -> Result<(), WebhookError>
pub async fn send_with_hints<T: Serialize + 'static>( &self, event: &T, hints: WithHints, ) -> Result<(), WebhookError>
Send using the internal matcher, with platform hints (color, title, etc).
Sourcepub async fn send_with_template<T: Serialize>(
&self,
template_name: &str,
event: &T,
) -> Result<(), WebhookError>
pub async fn send_with_template<T: Serialize>( &self, template_name: &str, event: &T, ) -> Result<(), WebhookError>
Send to an explicit template, bypassing the matcher entirely.
Sourcepub async fn send_with_template_and_hints<T: Serialize>(
&self,
template_name: &str,
event: &T,
hints: WithHints,
) -> Result<(), WebhookError>
pub async fn send_with_template_and_hints<T: Serialize>( &self, template_name: &str, event: &T, hints: WithHints, ) -> Result<(), WebhookError>
Send to an explicit template with platform hints.
Sourcepub async fn flush(&self) -> Result<(), WebhookError>
pub async fn flush(&self) -> Result<(), WebhookError>
Waits for all currently queued jobs to finish processing before returning. Use this between phases where template mutations depend on prior sends completing.
Auto Trait Implementations§
impl Freeze for WebhookDispatcher
impl !RefUnwindSafe for WebhookDispatcher
impl Send for WebhookDispatcher
impl Sync for WebhookDispatcher
impl Unpin for WebhookDispatcher
impl UnsafeUnpin for WebhookDispatcher
impl !UnwindSafe for WebhookDispatcher
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