Skip to main content

backbone_activity/exports/
events.rs

1//! Public events for Activity module
2//!
3//! Generated by metaphor-schema. Do not edit manually.
4//!
5//! These events are published by this module for other modules to subscribe to.
6//! Events are the primary mechanism for cross-module communication.
7
8use serde::{Deserialize, Serialize};
9use chrono::{DateTime, Utc};
10
11use super::types::*;
12
13// ============================================================================
14// ACTIVITY EVENTS
15// ============================================================================
16
17/// Event published when a Activity is created
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct ActivityCreatedEvent {
20    pub id: ActivityId,
21    pub data: ActivityDto,
22    pub occurred_at: DateTime<Utc>,
23}
24
25/// Event published when a Activity is updated
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct ActivityUpdatedEvent {
28    pub id: ActivityId,
29    pub data: ActivityDto,
30    pub occurred_at: DateTime<Utc>,
31}
32
33/// Event published when a Activity is deleted
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct ActivityDeletedEvent {
36    pub id: ActivityId,
37    pub occurred_at: DateTime<Utc>,
38}
39
40// ============================================================================
41// MODULE EVENT ENUM
42// ============================================================================
43
44/// All events published by Activity module
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(tag = "type")]
47pub enum ActivityEvent {
48    ActivityCreated(ActivityCreatedEvent),
49    ActivityUpdated(ActivityUpdatedEvent),
50    ActivityDeleted(ActivityDeletedEvent),
51}
52
53/// Metadata for module events
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct ActivityEventMetadata {
56    pub module: &'static str,
57    pub version: &'static str,
58}
59
60impl Default for ActivityEventMetadata {
61    fn default() -> Self {
62        Self {
63            module: "activity",
64            version: "1.0",
65        }
66    }
67}
68
69// ============================================================================
70// CUSTOM EVENTS
71// ============================================================================
72
73// <<< CUSTOM EVENTS START >>>
74// Add custom public events here
75// <<< CUSTOM EVENTS END >>>