pub use jmap_server::{
AddedItem, BackendChangesError, BackendSetError, ChangesResult, GetObject, JmapBackend,
JmapObject, QueryChangesResult, QueryObject, QueryResult, SetError, SetErrorType, SetObject,
};
pub use jmap_tasks_types::backend::{TaskListProperty, TaskNotificationProperty, TaskProperty};
pub use jmap_types::PatchObject;
pub trait TasksBackend: JmapBackend {
fn create_object<O: SetObject + Send + Sync>(
&self,
caller: &Self::CallerCtx,
account_id: &jmap_types::Id,
create_id: &str,
obj: O,
) -> impl std::future::Future<Output = Result<(jmap_types::Id, O), BackendSetError<Self::Error>>>
+ Send;
fn update_object<O: SetObject + Send + Sync>(
&self,
caller: &Self::CallerCtx,
account_id: &jmap_types::Id,
id: &jmap_types::Id,
patch: O::Patch,
) -> impl std::future::Future<Output = Result<Option<O>, BackendSetError<Self::Error>>> + Send;
fn destroy_object<O: SetObject + Send + Sync>(
&self,
caller: &Self::CallerCtx,
account_id: &jmap_types::Id,
id: &jmap_types::Id,
) -> impl std::future::Future<Output = Result<(), BackendSetError<Self::Error>>> + Send;
fn supports_type<O: JmapObject>(&self) -> bool;
fn copy_task(
&self,
caller: &Self::CallerCtx,
from_account_id: &jmap_types::Id,
to_account_id: &jmap_types::Id,
task: jmap_tasks_types::Task,
) -> impl std::future::Future<
Output = Result<(jmap_types::Id, jmap_tasks_types::Task), BackendSetError<Self::Error>>,
> + Send;
fn task_list_has_tasks(
&self,
caller: &Self::CallerCtx,
account_id: &jmap_types::Id,
task_list_id: &jmap_types::Id,
) -> impl std::future::Future<Output = bool> + Send;
fn is_per_user_property(prop: &str) -> bool {
matches!(
prop,
"keywords" | "color" | "freeBusyStatus" | "useDefaultAlerts" | "alerts"
)
}
fn update_task_per_user(
&self,
caller: &Self::CallerCtx,
account_id: &jmap_types::Id,
id: &jmap_types::Id,
patch: PatchObject,
) -> impl std::future::Future<
Output = Result<Option<jmap_tasks_types::Task>, BackendSetError<Self::Error>>,
> + Send {
self.update_object::<jmap_tasks_types::Task>(caller, account_id, id, patch)
}
fn enforce_is_draft_atomically(&self) -> bool {
false
}
fn compute_task_utc_times(
&self,
_task: &jmap_tasks_types::Task,
_tz_hint: Option<&str>,
) -> (Option<jmap_types::UTCDate>, Option<jmap_types::UTCDate>) {
(None, None)
}
}