use async_trait::async_trait;
use crate::types::{AddressBook, Calendar, Contact, Event, PutResult};
pub type StoreError = Box<dyn std::error::Error + Send + Sync>;
#[async_trait]
pub trait CalendarStore: Send + Sync {
async fn list_calendars(&self, user: &str) -> Result<Vec<Calendar>, StoreError>;
async fn get_calendar(
&self,
user: &str,
calendar_name: &str,
) -> Result<Option<Calendar>, StoreError>;
async fn list_events(&self, calendar_id: i64) -> Result<Vec<Event>, StoreError>;
async fn get_event(
&self,
calendar_id: i64,
uid: &str,
) -> Result<Option<Event>, StoreError>;
async fn event_etag(
&self,
calendar_id: i64,
uid: &str,
) -> Result<Option<String>, StoreError>;
async fn put_event(
&self,
calendar_id: i64,
uid: &str,
icalendar: &str,
etag: &str,
) -> Result<PutResult, StoreError>;
async fn delete_event(
&self,
calendar_id: i64,
uid: &str,
) -> Result<bool, StoreError>;
async fn ensure_default_calendar(&self, user: &str) -> Result<(), StoreError>;
}
#[async_trait]
pub trait AddressBookStore: Send + Sync {
async fn list_address_books(&self, user: &str) -> Result<Vec<AddressBook>, StoreError>;
async fn get_address_book(
&self,
user: &str,
book_name: &str,
) -> Result<Option<AddressBook>, StoreError>;
async fn list_contacts(&self, book_id: i64) -> Result<Vec<Contact>, StoreError>;
async fn get_contact(
&self,
book_id: i64,
uid: &str,
) -> Result<Option<Contact>, StoreError>;
async fn contact_etag(
&self,
book_id: i64,
uid: &str,
) -> Result<Option<String>, StoreError>;
async fn put_contact(
&self,
book_id: i64,
uid: &str,
vcard: &str,
etag: &str,
) -> Result<PutResult, StoreError>;
async fn delete_contact(&self, book_id: i64, uid: &str) -> Result<bool, StoreError>;
async fn ensure_default_address_book(&self, user: &str) -> Result<(), StoreError>;
}