pub struct Event<'a, P> { /* private fields */ }
Expand description
A captured record of something significant that occurred during the operation of a system.
Implementations§
Source§impl<'a, P> Event<'a, P>
impl<'a, P> Event<'a, P>
Sourcepub fn new(
mdl: impl Into<Path<'a>>,
tpl: impl Into<Template<'a>>,
extent: impl ToExtent,
props: P,
) -> Event<'a, P>
pub fn new( mdl: impl Into<Path<'a>>, tpl: impl Into<Template<'a>>, extent: impl ToExtent, props: P, ) -> Event<'a, P>
Construct an event from its parts.
Events are composed of:
mdl
: APath
to the module that produced the event. This will typically bemdl!()
orpkg!()
.tpl
: TheTemplate
of the event. This is the user-facing description of the event that can be rendered into a readable form.extent
: TheExtent
of the event. This is the point in time at which it occurred, or the timespan for which it was active.props
: TheProps
attached to the event, captured from the surrounding environment.
Sourcepub fn with_mdl(self, mdl: impl Into<Path<'a>>) -> Event<'a, P>
pub fn with_mdl(self, mdl: impl Into<Path<'a>>) -> Event<'a, P>
Set the module of the event, returning a new one.
Sourcepub fn extent(&self) -> Option<&Extent>
pub fn extent(&self) -> Option<&Extent>
Get a reference to the extent of the event, if there is one.
An event won’t have an extent if it was never constructed with one. This can happen in environments without access to a realtime clock.
Sourcepub fn with_extent(self, extent: impl ToExtent) -> Event<'a, P>
pub fn with_extent(self, extent: impl ToExtent) -> Event<'a, P>
Set the extent of the event, returning a new one.
Sourcepub fn ts(&self) -> Option<&Timestamp>
pub fn ts(&self) -> Option<&Timestamp>
Get the extent of the event as a point in time.
If the event has an extent then this method will return Some
, with the result of Extent::as_point
. If the event doesn’t have an extent then this method will return None
.
Sourcepub fn ts_start(&self) -> Option<&Timestamp>
pub fn ts_start(&self) -> Option<&Timestamp>
Get the start point of the extent of the event.
If the event has an extent, and that extent covers a timespan then this method will return Some
. Otherwise this method will return None
.
Sourcepub fn with_tpl(self, tpl: impl Into<Template<'a>>) -> Event<'a, P>
pub fn with_tpl(self, tpl: impl Into<Template<'a>>) -> Event<'a, P>
Set the template of the event, returning a new one.
Sourcepub fn with_props<U>(self, props: U) -> Event<'a, U>
pub fn with_props<U>(self, props: U) -> Event<'a, U>
Set the properties of the event, returning a new one.