Skip to main content

structscope_events/
lib.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Event {
7    pub event: String,
8    pub timestamp: DateTime<Utc>,
9    pub structure_id: Option<String>,
10    #[serde(default)]
11    pub details: Value,
12}
13
14impl Event {
15    pub fn new(event: impl Into<String>, structure_id: Option<String>, details: Value) -> Self {
16        Self {
17            event: event.into(),
18            timestamp: Utc::now(),
19            structure_id,
20            details,
21        }
22    }
23}