pub struct Event {
pub event_type: Arc<str>,
pub timestamp: DateTime<Utc>,
pub data: IndexMap<Arc<str>, Value, FxBuildHasher>,
}Expand description
A runtime event
Fields§
§event_type: Arc<str>Event type name (Arc<str> for O(1) clone instead of O(n) String clone).
timestamp: DateTime<Utc>Timestamp of the event (defaults to current server time if not provided).
data: IndexMap<Arc<str>, Value, FxBuildHasher>Event payload (uses Arc<str> keys for O(1) cloning, FxBuildHasher for faster access).
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(event_type: impl Into<Arc<str>>) -> Event
pub fn new(event_type: impl Into<Arc<str>>) -> Event
Creates a new event with the given type and current timestamp.
Sourcepub fn new_at(
event_type: impl Into<Arc<str>>,
timestamp: DateTime<Utc>,
) -> Event
pub fn new_at( event_type: impl Into<Arc<str>>, timestamp: DateTime<Utc>, ) -> Event
Creates a new event with a specific timestamp (avoids Utc::now() syscall).
Sourcepub fn with_capacity(event_type: impl Into<Arc<str>>, capacity: usize) -> Event
pub fn with_capacity(event_type: impl Into<Arc<str>>, capacity: usize) -> Event
Creates a new event with pre-allocated capacity for fields. Use this when you know the approximate number of fields in advance.
Sourcepub fn with_capacity_at(
event_type: impl Into<Arc<str>>,
capacity: usize,
timestamp: DateTime<Utc>,
) -> Event
pub fn with_capacity_at( event_type: impl Into<Arc<str>>, capacity: usize, timestamp: DateTime<Utc>, ) -> Event
Creates a new event with pre-allocated capacity and a specific timestamp.
Sourcepub fn from_fields(
event_type: impl Into<Arc<str>>,
data: IndexMap<Arc<str>, Value, FxBuildHasher>,
) -> Event
pub fn from_fields( event_type: impl Into<Arc<str>>, data: IndexMap<Arc<str>, Value, FxBuildHasher>, ) -> Event
Creates a new event from pre-built fields map. Use this when you already have the fields constructed (e.g., from JSON parsing).
Sourcepub fn from_string_fields(
event_type: impl Into<Arc<str>>,
data: IndexMap<String, Value, FxBuildHasher>,
) -> Event
pub fn from_string_fields( event_type: impl Into<Arc<str>>, data: IndexMap<String, Value, FxBuildHasher>, ) -> Event
Creates a new event from pre-built fields map with String keys (converts to Arc<str>).
Sourcepub fn from_fields_with_timestamp(
event_type: impl Into<Arc<str>>,
timestamp: DateTime<Utc>,
data: IndexMap<Arc<str>, Value, FxBuildHasher>,
) -> Event
pub fn from_fields_with_timestamp( event_type: impl Into<Arc<str>>, timestamp: DateTime<Utc>, data: IndexMap<Arc<str>, Value, FxBuildHasher>, ) -> Event
Creates a new event from pre-built fields map with a specific timestamp.
Sourcepub const fn with_timestamp(self, ts: DateTime<Utc>) -> Event
pub const fn with_timestamp(self, ts: DateTime<Utc>) -> Event
Sets the event’s timestamp (builder pattern).
Sourcepub fn with_field(
self,
key: impl Into<Arc<str>>,
value: impl Into<Value>,
) -> Event
pub fn with_field( self, key: impl Into<Arc<str>>, value: impl Into<Value>, ) -> Event
Adds a field to the event (builder pattern).
Sourcepub fn get_str(&self, key: &str) -> Option<&str>
pub fn get_str(&self, key: &str) -> Option<&str>
Looks up a field and extracts it as a string slice.
Sourcepub fn to_sink_payload(&self) -> Vec<u8> ⓘ
pub fn to_sink_payload(&self) -> Vec<u8> ⓘ
Serialize for sink output: event_type + timestamp + data fields.
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>,
Source§impl From<&Event> for SerializableEvent
impl From<&Event> for SerializableEvent
Source§impl From<HVACStatus> for Event
impl From<HVACStatus> for Event
Source§fn from(s: HVACStatus) -> Self
fn from(s: HVACStatus) -> Self
Source§impl From<HumidityReading> for Event
impl From<HumidityReading> for Event
Source§fn from(r: HumidityReading) -> Self
fn from(r: HumidityReading) -> Self
Source§impl From<SerializableEvent> for Event
impl From<SerializableEvent> for Event
Source§fn from(se: SerializableEvent) -> Self
fn from(se: SerializableEvent) -> Self
Source§impl From<TemperatureReading> for Event
impl From<TemperatureReading> for Event
Source§fn from(r: TemperatureReading) -> Self
fn from(r: TemperatureReading) -> Self
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,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more