pub struct Event {
pub event_type: EventType,
pub version: u16,
pub timestamp_ms: u64,
pub correlation_id: String,
pub source: String,
pub data: HashMap<String, String>,
pub severity: EventSeverity,
pub event_id: String,
}Expand description
Versioned event data used by the opt-in historical scanner event bus.
§Examples
use termivar_core::{Event, EventSeverity, EventType};
let event = Event::builder(EventType::PhaseStarted, "scanner")
.correlation_id("scan-42")
.severity(EventSeverity::Info)
.data("phase", "recon")
.build();
assert_eq!(event.event_type, EventType::PhaseStarted);
assert_eq!(event.correlation_id, "scan-42");Fields§
§event_type: EventType§version: u16§timestamp_ms: u64§correlation_id: String§source: String§data: HashMap<String, String>§severity: EventSeverity§event_id: StringImplementations§
Source§impl Event
impl Event
Sourcepub fn new(event_type: EventType, source: impl Into<String>) -> Self
pub fn new(event_type: EventType, source: impl Into<String>) -> Self
Creates an event with a generated timestamp, correlation ID, and event ID.
Sourcepub fn builder(event_type: EventType, source: impl Into<String>) -> EventBuilder
pub fn builder(event_type: EventType, source: impl Into<String>) -> EventBuilder
Creates a fluent event builder.
Sourcepub fn with_correlation_id(self, scan_id: impl Into<String>) -> Self
pub fn with_correlation_id(self, scan_id: impl Into<String>) -> Self
Replaces the correlation ID.
Sourcepub fn with_data(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with_data(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds a custom data field.
Sourcepub fn with_severity(self, severity: EventSeverity) -> Self
pub fn with_severity(self, severity: EventSeverity) -> Self
Replaces the event severity.
Sourcepub fn with_version(self, version: u16) -> Self
pub fn with_version(self, version: u16) -> Self
Replaces the event schema version.
Sourcepub fn timestamp_str(&self) -> String
pub fn timestamp_str(&self) -> String
Returns the timestamp in seconds.milliseconds form.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more