pub struct Event {
pub topic: Topic,
pub payload: String,
pub source: Option<HatId>,
pub target: Option<HatId>,
pub wave_id: Option<String>,
pub wave_index: Option<u32>,
pub wave_total: Option<u32>,
}Expand description
An event in the pub/sub system.
Fields§
§topic: TopicThe routing topic for this event.
payload: StringThe content/payload of the event.
source: Option<HatId>The hat that published this event (if any).
target: Option<HatId>Optional target hat for direct handoff.
wave_id: Option<String>Wave correlation ID (e.g., “w-1a2b3c4d”).
wave_index: Option<u32>Index of this event within the wave (0-based).
wave_total: Option<u32>Total number of events in the wave.
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(topic: impl Into<Topic>, payload: impl Into<String>) -> Self
pub fn new(topic: impl Into<Topic>, payload: impl Into<String>) -> Self
Creates a new event with the given topic and payload.
Sourcepub fn with_source(self, source: impl Into<HatId>) -> Self
pub fn with_source(self, source: impl Into<HatId>) -> Self
Sets the source hat for this event.
Sourcepub fn with_target(self, target: impl Into<HatId>) -> Self
pub fn with_target(self, target: impl Into<HatId>) -> Self
Sets the target hat for direct handoff.
Sourcepub fn with_wave(
self,
wave_id: impl Into<String>,
index: u32,
total: u32,
) -> Self
pub fn with_wave( self, wave_id: impl Into<String>, index: u32, total: u32, ) -> Self
Sets wave correlation metadata on this event.
Sourcepub fn is_wave_event(&self) -> bool
pub fn is_wave_event(&self) -> bool
Returns true if this event has wave correlation metadata.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more