pub trait HookSink: Send + Sync {
// Required method
fn emit<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 HookEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
A destination that can receive HookEvents.
Implementors handle the transport-specific details of delivering events
(writing to stdout, appending to a file, POSTing to a webhook, etc.).
The HookDispatcher fans out every event to all registered sinks, so a
single process can log to multiple destinations simultaneously.
Sinks are expected to be best-effort: implementations should avoid
panicking and should return an anyhow::Error only for truly unexpected
failures. HookDispatcher::emit discards individual sink errors so hook
delivery failures do not abort the application.
Required Methods§
Sourcefn emit<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 HookEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn emit<'life0, 'life1, 'async_trait>(
&'life0 self,
event: &'life1 HookEvent,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deliver a single event to this sink.
Implementations should be resilient to transient failures (e.g. a missing listener) and should not block the caller for extended periods.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".