use crate::error::CoreError;
use crate::ids::{ETag, ResourcePath};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Calendar {
pub path: ResourcePath,
pub name: String,
pub holds_events: bool,
pub holds_tasks: bool,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EventQuery {
pub calendars: Vec<ResourcePath>,
pub start: String,
pub end: String,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Event {
pub path: ResourcePath,
pub etag: ETag,
pub uid: String,
pub summary: String,
pub description: String,
pub start: String,
pub end: String,
pub time_zone: Option<String>,
pub all_day: bool,
pub recurring: bool,
pub recurrence_id: Option<String>,
pub attendees: Vec<String>,
pub alarms: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EventList {
pub events: Vec<Event>,
pub warnings: u32,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EventDraft {
pub summary: String,
pub description: Option<String>,
pub start: String,
pub end: String,
pub time_zone: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum UpdateScope {
Series,
Occurrence {
recurrence_id: String,
},
}
#[trait_variant::make(Send)]
pub trait CalendarProvider {
async fn list_calendars(&self) -> Result<Vec<Calendar>, CoreError>;
async fn list_events(&self, query: &EventQuery) -> Result<EventList, CoreError>;
async fn get_event(&self, path: &ResourcePath) -> Result<Event, CoreError>;
async fn create_event(
&self,
calendar: &ResourcePath,
draft: &EventDraft,
) -> Result<ResourcePath, CoreError>;
async fn update_event(
&self,
path: &ResourcePath,
etag: &ETag,
draft: &EventDraft,
scope: &UpdateScope,
) -> Result<ETag, CoreError>;
async fn delete_event(&self, path: &ResourcePath, etag: &ETag) -> Result<(), CoreError>;
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReminderList {
pub path: ResourcePath,
pub name: String,
}
pub const UPGRADED_LISTS_NOTE: &str = "Only old-style reminder lists are shown. Lists that the Reminders app upgraded to the newer format can't be reached through iCloud's calendar service, so they are missing here and can't be read or changed.";
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum CompletedFilter {
All,
Open,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Reminder {
pub path: ResourcePath,
pub etag: ETag,
pub title: String,
pub notes: String,
pub due: Option<String>,
pub priority: Option<u8>,
pub completed: bool,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReminderPage {
pub reminders: Vec<Reminder>,
pub warnings: u32,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReminderDraft {
pub title: String,
pub notes: String,
pub due: Option<String>,
pub priority: Option<u8>,
pub completed: bool,
}
#[trait_variant::make(Send)]
pub trait RemindersProvider {
async fn list_lists(&self) -> Result<Vec<ReminderList>, CoreError>;
async fn list(
&self,
list: Option<&ResourcePath>,
completed: CompletedFilter,
) -> Result<ReminderPage, CoreError>;
async fn get(&self, path: &ResourcePath) -> Result<Reminder, CoreError>;
async fn create(
&self,
list: &ResourcePath,
draft: &ReminderDraft,
) -> Result<ResourcePath, CoreError>;
async fn update(
&self,
path: &ResourcePath,
etag: &ETag,
draft: &ReminderDraft,
) -> Result<ETag, CoreError>;
async fn delete(&self, path: &ResourcePath, etag: &ETag) -> Result<(), CoreError>;
}