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
impl InMemoryAlertHook
Sourcepub fn new(identifier: String) -> Self
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.
Sourcepub fn sent_alerts(&self) -> Vec<Alert>
pub fn sent_alerts(&self) -> Vec<Alert>
Returns a snapshot (copy) of the alerts “sent” so far.
Sourcepub fn identifier(&self) -> &str
pub fn identifier(&self) -> &str
Exposes the configured identifier for caller debugging or assertions.
Sourcepub fn url(&self) -> &str
👎Deprecated since 1.2.0: use identifier() instead; this hook does not perform HTTP
pub fn url(&self) -> &str
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.