mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 20:32:48 +00:00
85 lines
2.4 KiB
Rust
85 lines
2.4 KiB
Rust
use crate::{Calendar, error::Error};
|
|
use async_trait::async_trait;
|
|
use chrono::NaiveDate;
|
|
use rustical_ical::CalendarObject;
|
|
|
|
#[derive(Default, Debug, Clone)]
|
|
pub struct CalendarQuery {
|
|
pub time_start: Option<NaiveDate>,
|
|
pub time_end: Option<NaiveDate>,
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait CalendarStore: Send + Sync + 'static {
|
|
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error>;
|
|
async fn get_calendars(&self, principal: &str) -> Result<Vec<Calendar>, Error>;
|
|
async fn get_deleted_calendars(&self, principal: &str) -> Result<Vec<Calendar>, Error>;
|
|
|
|
async fn update_calendar(
|
|
&self,
|
|
principal: String,
|
|
id: String,
|
|
calendar: Calendar,
|
|
) -> Result<(), Error>;
|
|
async fn insert_calendar(&self, calendar: Calendar) -> Result<(), Error>;
|
|
async fn delete_calendar(
|
|
&self,
|
|
principal: &str,
|
|
name: &str,
|
|
use_trashbin: bool,
|
|
) -> Result<(), Error>;
|
|
async fn restore_calendar(&self, principal: &str, name: &str) -> Result<(), Error>;
|
|
|
|
async fn sync_changes(
|
|
&self,
|
|
principal: &str,
|
|
cal_id: &str,
|
|
synctoken: i64,
|
|
) -> Result<(Vec<CalendarObject>, Vec<String>, i64), Error>;
|
|
|
|
/// Since the <calendar-query> rules are rather complex this function
|
|
/// is only meant to do some prefiltering
|
|
async fn calendar_query(
|
|
&self,
|
|
principal: &str,
|
|
cal_id: &str,
|
|
_query: CalendarQuery,
|
|
) -> Result<Vec<CalendarObject>, Error> {
|
|
self.get_objects(principal, cal_id).await
|
|
}
|
|
|
|
async fn get_objects(
|
|
&self,
|
|
principal: &str,
|
|
cal_id: &str,
|
|
) -> Result<Vec<CalendarObject>, Error>;
|
|
async fn get_object(
|
|
&self,
|
|
principal: &str,
|
|
cal_id: &str,
|
|
object_id: &str,
|
|
) -> Result<CalendarObject, Error>;
|
|
async fn put_object(
|
|
&self,
|
|
principal: String,
|
|
cal_id: String,
|
|
object: CalendarObject,
|
|
overwrite: bool,
|
|
) -> Result<(), Error>;
|
|
async fn delete_object(
|
|
&self,
|
|
principal: &str,
|
|
cal_id: &str,
|
|
object_id: &str,
|
|
use_trashbin: bool,
|
|
) -> Result<(), Error>;
|
|
async fn restore_object(
|
|
&self,
|
|
principal: &str,
|
|
cal_id: &str,
|
|
object_id: &str,
|
|
) -> Result<(), Error>;
|
|
|
|
fn is_read_only(&self, cal_id: &str) -> bool;
|
|
}
|