feat: Improve database handling of model indices #6
@ -101,6 +101,16 @@ pub struct Event {
|
||||
}
|
||||
|
||||
impl Event {
|
||||
/// Converts the event to a JSON string
|
||||
pub fn to_json(&self) -> Result<String, serde_json::Error> {
|
||||
serde_json::to_string(self)
|
||||
}
|
||||
|
||||
/// Creates an event from a JSON string
|
||||
pub fn from_json(json: &str) -> Result<Self, serde_json::Error> {
|
||||
serde_json::from_str(json)
|
||||
}
|
||||
|
||||
/// Creates a new event with auto-generated ID
|
||||
pub fn new(title: impl ToString, start_time: DateTime<Utc>, end_time: DateTime<Utc>) -> Self {
|
||||
Self {
|
||||
|
Loading…
Reference in New Issue
Block a user