pub struct SubscriptionEvent {
pub event_id: String,
pub entity_type: String,
pub entity_id: String,
pub operation: SubscriptionOperation,
pub timestamp: DateTime<Utc>,
pub sequence_number: u64,
pub data: Value,
pub old_data: Option<Value>,
}Expand description
An event from the database that may trigger subscriptions.
This is the internal event format, captured from LISTEN/NOTIFY or CDC.
Fields§
§event_id: StringUnique event identifier.
entity_type: StringEntity type name (e.g., “Order”, “User”).
entity_id: StringEntity primary key.
operation: SubscriptionOperationDatabase operation that created this event.
timestamp: DateTime<Utc>Event timestamp (from database).
sequence_number: u64Monotonic sequence number for ordering.
data: ValueEvent payload data (the row data as JSON).
old_data: Option<Value>Optional old data (for UPDATE operations).
Implementations§
Source§impl SubscriptionEvent
impl SubscriptionEvent
Sourcepub fn new(
entity_type: impl Into<String>,
entity_id: impl Into<String>,
operation: SubscriptionOperation,
data: Value,
) -> Self
pub fn new( entity_type: impl Into<String>, entity_id: impl Into<String>, operation: SubscriptionOperation, data: Value, ) -> Self
Create a new subscription event.
Sourcepub fn with_old_data(self, old_data: Value) -> Self
pub fn with_old_data(self, old_data: Value) -> Self
Add old data for UPDATE operations.
Sourcepub fn with_sequence(self, seq: u64) -> Self
pub fn with_sequence(self, seq: u64) -> Self
Set the sequence number.
Trait Implementations§
Source§impl Clone for SubscriptionEvent
impl Clone for SubscriptionEvent
Source§fn clone(&self) -> SubscriptionEvent
fn clone(&self) -> SubscriptionEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SubscriptionEvent
impl Debug for SubscriptionEvent
Source§impl<'de> Deserialize<'de> for SubscriptionEvent
impl<'de> Deserialize<'de> for SubscriptionEvent
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 SubscriptionEvent
impl RefUnwindSafe for SubscriptionEvent
impl Send for SubscriptionEvent
impl Sync for SubscriptionEvent
impl Unpin for SubscriptionEvent
impl UnsafeUnpin for SubscriptionEvent
impl UnwindSafe for SubscriptionEvent
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