/// Publish an event. This is the main interface that client code will
/// use.
///
/// If `init_stream` has not been called already, this function will
/// be a no-op.
Publish an event. This is the main interface that client code will
use.

If `init_stream` has not been called already, this function will
be a no-op.
Publish an event . This is the main interface that client code will use . If ` init_stream ` has not been called already this function will be a no - op .
fn publish(mut event: impl EventMessage) {
    if let Some(e) = EVENT_STREAM.try_get::<EventStream>() {
        // TODO (CM): Yeah... this is looking pretty gross. The
        // intention is to be able to timestamp the events right as
        // they go out.
        //
        // We *could* set the time when we convert the EventCore to a
        // EventMetadata struct, but that seems odd.
        //
        // It probably means that this structure just isn't the right
        // one.
        //
        // The ugliness is at least contained, though.
        debug!("Publishing to event stream: event {:?} ", event);
        event.event_metadata(EventMetadata { occurred_at:
                                                 Some(std::time::SystemTime::now().into()),
                                             ..EVENT_CORE.get::<EventCore>().to_event_metadata() });
        e.send(event.to_bytes());
    }
}
fn publish ( mut event : impl EventMessage ) { if let Some ( e ) = EVENT_STREAM . try_get :: < EventStream > ( ) { // TODO (CM): Yeah... this is looking pretty gross. The // intention is to be able to timestamp the events right as // they go out. // // We *could* set the time when we convert the EventCore to a // EventMetadata struct, but that seems odd. // // It probably means that this structure just isn't the right // one. // // The ugliness is at least contained, though. debug ! ( " " event ) ; event . event_metadata ( EventMetadata { occurred_at : Some ( std :: time :: SystemTime :: now ( ) . into ( ) ) , .. EVENT_CORE . get :: < EventCore > ( ) . to_event_metadata ( ) } ) ; e . send ( event . to_bytes ( ) ) ; } }
Publish an event.
Publish an event .
event
impl EventMessage