use async_trait::async_trait; use super::{ calendar::Calendar, event::Event, recurrence::RecurringEvent, value_objects::{CalendarId, EventId, TimeRange}, }; pub type Result = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum RepositoryError { #[error("Entity not found")] NotFound, #[error("Database error: {0}")] DatabaseError(String), #[error("Constraint violation: {0}")] ConstraintViolation(String), } #[async_trait] pub trait CalendarRepository: Send + Sync { async fn save(&self, calendar: &Calendar) -> Result<()>; async fn find_by_id(&self, id: &CalendarId) -> Result>; async fn find_all_active(&self) -> Result>; async fn delete(&self, id: &CalendarId) -> Result<()>; } #[async_trait] pub trait EventRepository: Send + Sync { async fn save(&self, event: &Event) -> Result<()>; async fn find_by_id(&self, id: &EventId) -> Result>; async fn find_by_calendar(&self, calendar_id: &CalendarId) -> Result>; async fn find_in_range(&self, calendar_id: &CalendarId, range: &TimeRange) -> Result>; async fn delete(&self, id: &EventId) -> Result<()>; } #[async_trait] pub trait RecurringEventRepository: Send + Sync { async fn save(&self, event: &RecurringEvent) -> Result<()>; async fn find_by_calendar(&self, calendar_id: &CalendarId) -> Result>; async fn delete(&self, id: &str) -> Result<()>; }