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>) -> Event
pub fn new(event_type: EventType, source: impl Into<String>) -> Event
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>) -> Event
pub fn with_correlation_id(self, scan_id: impl Into<String>) -> Event
Replaces the correlation ID.
Sourcepub fn with_data(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Event
pub fn with_data( self, key: impl Into<String>, value: impl Into<String>, ) -> Event
Adds a custom data field.
Sourcepub fn with_severity(self, severity: EventSeverity) -> Event
pub fn with_severity(self, severity: EventSeverity) -> Event
Replaces the event severity.
Sourcepub fn with_version(self, version: u16) -> Event
pub fn with_version(self, version: u16) -> Event
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<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Event, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Event
impl Serialize for Event
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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