This commit is contained in:
2025-04-20 09:34:18 +02:00
parent 59c9b445bb
commit 616d3247b6
8 changed files with 48 additions and 56 deletions

View File

@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::db::{SledModel, Storable, SledDB, SledDBResult};
use crate::db::{Model, Storable, DB, DbError, DbResult};
use crate::models::mcc::event::Event;
/// Calendar represents a calendar container for events
@@ -51,13 +51,12 @@ impl Calendar {
}
}
// Implement Storable trait (provides default dump/load)
impl Storable for Calendar {}
impl Storable for Calendar{}
// Implement SledModel trait
impl SledModel for Calendar {
fn get_id(&self) -> String {
self.id.to_string()
// Implement Model trait
impl Model for Calendar {
fn get_id(&self) -> u32 {
self.id
}
fn db_prefix() -> &'static str {

View File

@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::db::{SledModel, Storable, SledDB, SledDBResult};
use crate::db::{Model, Storable, DB, DbError, DbResult};
use crate::models::mcc::event::Event;
use chrono::Utc;
@@ -63,8 +63,8 @@ impl Contact {
}
/// Get events where this contact is an attendee
pub fn get_events(&self, db: &SledDB<Event>) -> SledDBResult<Vec<Event>> {
let all_events = db.list()?;
pub fn get_events(&self, db: &DB) -> DbResult<Vec<Event>> {
let all_events = db.list::<Event>()?;
let contact_events = all_events
.into_iter()
.filter(|event| event.attendees.contains(&self.email))
@@ -110,12 +110,12 @@ impl Contact {
impl Storable for Contact {}
// Implement SledModel trait
impl SledModel for Contact {
fn get_id(&self) -> String {
self.id.to_string()
impl Model for Contact {
fn get_id(&self) -> u32 {
self.id
}
fn db_prefix() -> &'static str {
"contact"
}
}
}

View File

@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::db::{SledModel, Storable, SledDB, SledDBResult};
use crate::db::{Model, Storable, DB, DbError, DbResult};
use crate::models::mcc::calendar::Calendar;
use crate::models::mcc::contacts::Contact;
use chrono::{DateTime, Utc};

View File

@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::db::{SledModel, Storable, SledDBResult, SledDB};
use crate::db::{Model, Storable, DB, DbError, DbResult};
use chrono::Utc;
/// Email represents an email message with all its metadata and content

View File

@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::db::{SledModel, Storable, SledDB, SledDBResult};
use crate::db::{Model, Storable, DB, DbError, DbResult};
use chrono::{DateTime, Utc};
/// MessageStatus represents the status of a message

View File

@@ -12,4 +12,4 @@ pub use contacts::Contact;
pub use message::{Message, MessageMeta, MessageStatus};
// Re-export database components from db module
pub use crate::db::{SledDB, SledDBError, SledDBResult, Storable, SledModel, DB};
pub use crate::db::{DB, DBBuilder, Model, Storable, DbError, DbResult};