emit_core::event

Struct Event

Source
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>

Source

pub fn new( mdl: impl Into<Path<'a>>, tpl: impl Into<Template<'a>>, extent: impl ToExtent, props: P, ) -> Self

Construct an event from its parts.

Events are composed of:

  • mdl: A Path to the module that produced the event. This will typically be mdl!() or pkg!().
  • tpl: The Template of the event. This is the user-facing description of the event that can be rendered into a readable form.
  • extent: The Extent of the event. This is the point in time at which it occurred, or the timespan for which it was active.
  • props: The Props attached to the event, captured from the surrounding environment.
Source

pub fn mdl(&self) -> &Path<'a>

Get a reference to the module that produced the event.

Source

pub fn with_mdl(self, mdl: impl Into<Path<'a>>) -> Self

Set the module of the event, returning a new one.

Source

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.

Source

pub fn with_extent(self, extent: impl ToExtent) -> Self

Set the extent of the event, returning a new one.

Source

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.

Source

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.

Source

pub fn tpl(&self) -> &Template<'a>

Get a reference to the template of the event.

Source

pub fn with_tpl(self, tpl: impl Into<Template<'a>>) -> Self

Set the template of the event, returning a new one.

Source

pub fn props(&self) -> &P

Get a reference to the properties of the event.

Source

pub fn with_props<U>(self, props: U) -> Event<'a, U>

Set the properties of the event, returning a new one.

Source

pub fn map_props<U>(self, map: impl FnOnce(P) -> U) -> Event<'a, U>

Map the properties of the event, returning a new one.

Source§

impl<'a, P: Props> Event<'a, P>

Source

pub fn msg(&self) -> Render<'_, &P>

Get a lazily-evaluated formatting of the event’s template.

Source

pub fn by_ref<'b>(&'b self) -> Event<'b, &'b P>

Get a new event, borrowing data from this one.

Source

pub fn erase<'b>(&'b self) -> Event<'b, &'b dyn ErasedProps>

Get a type-erased event, borrowing data from this one.

Trait Implementations§

Source§

impl<'a, P: Clone> Clone for Event<'a, P>

Source§

fn clone(&self) -> Event<'a, P>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, P: Props> Debug for Event<'a, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, P: Props> ToEvent for Event<'a, P>

Source§

type Props<'b> = &'b P where Self: 'b

The kind of Props on the resulting value.
Source§

fn to_event<'b>(&'b self) -> Event<'b, Self::Props<'b>>

Perform the conversion.

Auto Trait Implementations§

§

impl<'a, P> Freeze for Event<'a, P>
where P: Freeze,

§

impl<'a, P> RefUnwindSafe for Event<'a, P>
where P: RefUnwindSafe,

§

impl<'a, P> Send for Event<'a, P>
where P: Send,

§

impl<'a, P> Sync for Event<'a, P>
where P: Sync,

§

impl<'a, P> Unpin for Event<'a, P>
where P: Unpin,

§

impl<'a, P> UnwindSafe for Event<'a, P>
where P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.