pub trait AuditSink: Send + Sync {
// Required methods
fn record(&self, event: AuditEvent) -> Result<(), AuditError>;
fn flush(&self) -> Result<(), AuditError>;
// Provided method
fn is_healthy(&self) -> bool { ... }
}Expand description
Trait for audit event sinks
Framework users implement this trait to customize where audit events are sent.
§Example
use sen_plugin_host::audit::{AuditSink, AuditEvent, AuditError};
struct MyCloudAuditSink {
endpoint: String,
}
impl AuditSink for MyCloudAuditSink {
fn record(&self, event: AuditEvent) -> Result<(), AuditError> {
// Send to cloud service
println!("Would send to {}: {:?}", self.endpoint, event);
Ok(())
}
fn flush(&self) -> Result<(), AuditError> {
Ok(())
}
}Required Methods§
Sourcefn record(&self, event: AuditEvent) -> Result<(), AuditError>
fn record(&self, event: AuditEvent) -> Result<(), AuditError>
Record an audit event
Sourcefn flush(&self) -> Result<(), AuditError>
fn flush(&self) -> Result<(), AuditError>
Flush any buffered events
Provided Methods§
Sourcefn is_healthy(&self) -> bool
fn is_healthy(&self) -> bool
Check if the sink is healthy/available