pub struct EventEnvelope<P> {
pub id: EventId,
pub name: EventName,
pub kind: EventKind,
pub source: EventSource,
pub target: Option<EventTarget>,
pub timestamp: EventTimestamp,
pub metadata: EventMetadata,
pub payload: P,
}Fields§
§id: EventId§name: EventName§kind: EventKind§source: EventSource§target: Option<EventTarget>§timestamp: EventTimestamp§metadata: EventMetadata§payload: PImplementations§
Source§impl<P> EventEnvelope<P>
impl<P> EventEnvelope<P>
Sourcepub fn new(
name: EventName,
kind: EventKind,
source: EventSource,
payload: P,
) -> EventEnvelope<P>
pub fn new( name: EventName, kind: EventKind, source: EventSource, payload: P, ) -> EventEnvelope<P>
Examples found in repository?
examples/basic_usage.rs (lines 5-10)
4fn main() {
5 let event = EventEnvelope::new(
6 EventName::new("command.started"),
7 EventKind::Started,
8 EventSource::new("cli"),
9 "rustuse build",
10 );
11
12 assert_eq!(event.name.as_str(), "command.started");
13 assert_eq!(event.payload, "rustuse build");
14
15 let mut log = EventLog::new();
16 log.append(EventName::new("test.started"));
17 log.append(EventName::new("test.passed"));
18
19 assert_eq!(log.len(), 2);
20 assert_eq!(log.last().map(EventName::as_str), Some("test.passed"));
21}pub fn with_id(self, id: impl Into<EventId>) -> EventEnvelope<P>
pub fn with_target(self, target: impl Into<EventTarget>) -> EventEnvelope<P>
pub fn with_metadata(self, metadata: EventMetadata) -> EventEnvelope<P>
pub fn with_timestamp(self, timestamp: EventTimestamp) -> EventEnvelope<P>
Trait Implementations§
Source§impl<P> Clone for EventEnvelope<P>where
P: Clone,
impl<P> Clone for EventEnvelope<P>where
P: Clone,
Source§fn clone(&self) -> EventEnvelope<P>
fn clone(&self) -> EventEnvelope<P>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<P> Debug for EventEnvelope<P>where
P: Debug,
impl<P> Debug for EventEnvelope<P>where
P: Debug,
Source§impl<P> PartialEq for EventEnvelope<P>where
P: PartialEq,
impl<P> PartialEq for EventEnvelope<P>where
P: PartialEq,
Source§fn eq(&self, other: &EventEnvelope<P>) -> bool
fn eq(&self, other: &EventEnvelope<P>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<P> Eq for EventEnvelope<P>where
P: Eq,
impl<P> StructuralPartialEq for EventEnvelope<P>
Auto Trait Implementations§
impl<P> Freeze for EventEnvelope<P>where
P: Freeze,
impl<P> RefUnwindSafe for EventEnvelope<P>where
P: RefUnwindSafe,
impl<P> Send for EventEnvelope<P>where
P: Send,
impl<P> Sync for EventEnvelope<P>where
P: Sync,
impl<P> Unpin for EventEnvelope<P>where
P: Unpin,
impl<P> UnsafeUnpin for EventEnvelope<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for EventEnvelope<P>where
P: UnwindSafe,
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