#[non_exhaustive]pub struct AuditEvent {
pub ts: SystemTime,
pub event: &'static str,
pub url_scheme: String,
pub dst_scheme: Option<String>,
pub outcome: &'static str,
pub error_kind: Option<&'static str>,
}Expand description
A redacted audit event.
Constructed via AuditEvent::start or AuditEvent::done; the
struct is #[non_exhaustive] so external crates cannot widen the
field set by struct-literal initialization. Sink implementations
receive &AuditEvent and can serialize whichever fields they
expose — but every field is, by construction, value-free.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.ts: SystemTime§event: &'static str§url_scheme: String§dst_scheme: Option<String>§outcome: &'static str§error_kind: Option<&'static str>Implementations§
Source§impl AuditEvent
impl AuditEvent
Sourcepub fn start(verb: Verb, scheme: impl Into<String>) -> Self
pub fn start(verb: Verb, scheme: impl Into<String>) -> Self
Build a *.start event for verb operating on a URL with
scheme. Default outcome is "started".
Sourcepub fn done(
verb: Verb,
scheme: impl Into<String>,
outcome: &'static str,
) -> Self
pub fn done( verb: Verb, scheme: impl Into<String>, outcome: &'static str, ) -> Self
Build a *.done event for verb with the given outcome label.
Sourcepub fn with_dst_scheme(self, dst_scheme: impl Into<String>) -> Self
pub fn with_dst_scheme(self, dst_scheme: impl Into<String>) -> Self
Attach a destination scheme (used by cp, diff, and any future
two-URL verb).
Sourcepub fn with_error_kind(self, kind: &'static str) -> Self
pub fn with_error_kind(self, kind: &'static str) -> Self
Attach a stable error-kind classifier (from Error::kind()).
Sourcepub fn with_event(
event: &'static str,
scheme: impl Into<String>,
outcome: &'static str,
) -> Self
pub fn with_event( event: &'static str, scheme: impl Into<String>, outcome: &'static str, ) -> Self
Build an event with an arbitrary 'static event label.
CLI-only verbs that do not belong on the library-side Verb
enum (e.g., run.start / run.done from subprocess env
injection) build events through this constructor. The
&'static str bound prevents runtime-built label strings from
smuggling value bytes into the audit envelope: callers must
pass string literals known at compile time.
Sourcepub fn cache(kind: CacheEvent, scheme: impl Into<String>) -> Self
pub fn cache(kind: CacheEvent, scheme: impl Into<String>) -> Self
Build a cache event for the given URL scheme. Single-phase —
the outcome field carries the same classifier as event
(e.g., event = "cache.hit", outcome = "hit") so consumers
that filter on outcome see a stable label without parsing
the event prefix.
Sourcepub fn to_json_line(&self) -> String
pub fn to_json_line(&self) -> String
Render to a single-line JSON string with no trailing newline.
Wire format (fields appear in this order):
{"event":"get.done","ts":1234567890,"src_scheme":"vault","outcome":"ok"}dst_scheme and error_kind appear only when populated. The
timestamp is UNIX seconds since the epoch; clock-skew anomalies
fall back to 0 rather than panicking on the secret path.
Trait Implementations§
Source§impl Clone for AuditEvent
impl Clone for AuditEvent
Source§fn clone(&self) -> AuditEvent
fn clone(&self) -> AuditEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more