Skip to main content

InMemoryAlertHook

Struct InMemoryAlertHook 

Source
pub struct InMemoryAlertHook { /* private fields */ }
Expand description

In-memory alert hook (not a real webhook): stores alerts in memory without any network sends.

The type name is deliberately changed to InMemoryAlertHook (the original WebhookAlertHook name suggested HTTP calls, but it actually only pushes to a Vec, which would mislead users). The identifier field is used only for test assertions and debugging, and is not used for any HTTP request.

For real webhook push, implement a custom AlertHook and use reqwest or hyper to make HTTP requests in notify.

Used for testing and local development environments; dispatched alerts can be inspected via sent_alerts.

Implementations§

Source§

impl InMemoryAlertHook

Source

pub fn new(identifier: String) -> Self

Creates an in-memory alert hook. identifier is only a debug label and does not participate in network calls.

Source

pub fn sent_alerts(&self) -> Vec<Alert>

Returns a snapshot (copy) of the alerts “sent” so far.

Source

pub fn identifier(&self) -> &str

Exposes the configured identifier for caller debugging or assertions.

Source

pub fn url(&self) -> &str

👎Deprecated since 1.2.0:

use identifier() instead; this hook does not perform HTTP

Backward compatibility: returns the identifier (alias of the original url field).

§Deprecated

This method is retained only to reduce breaking changes; new code should use identifier.

Trait Implementations§

Source§

impl AlertHook for InMemoryAlertHook

Source§

fn notify(&self, alert: &Alert) -> Result<(), String>

Handles an alert event. Returns Ok(()) on success, or an error description string on failure.

Auto Trait Implementations§

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, 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, 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.