rustical_store/
addressbook_store.rs1use crate::{CollectionMetadata, Error, addressbook::Addressbook};
2use async_trait::async_trait;
3use rustical_ical::AddressObject;
4
5#[async_trait]
6pub trait AddressbookStore: Send + Sync + 'static {
7 async fn get_addressbook(
8 &self,
9 principal: &str,
10 id: &str,
11 show_deleted: bool,
12 ) -> Result<Addressbook, Error>;
13 async fn get_addressbooks(&self, principal: &str) -> Result<Vec<Addressbook>, Error>;
14 async fn get_deleted_addressbooks(&self, principal: &str) -> Result<Vec<Addressbook>, Error>;
15
16 async fn update_addressbook(
17 &self,
18 principal: &str,
19 id: &str,
20 addressbook: Addressbook,
21 ) -> Result<(), Error>;
22 async fn insert_addressbook(&self, addressbook: Addressbook) -> Result<(), Error>;
23 async fn delete_addressbook(
24 &self,
25 principal: &str,
26 name: &str,
27 use_trashbin: bool,
28 ) -> Result<(), Error>;
29 async fn restore_addressbook(&self, principal: &str, name: &str) -> Result<(), Error>;
30
31 async fn sync_changes(
32 &self,
33 principal: &str,
34 addressbook_id: &str,
35 synctoken: i64,
36 ) -> Result<(Vec<(String, AddressObject)>, Vec<String>, i64), Error>;
37
38 async fn addressbook_metadata(
39 &self,
40 principal: &str,
41 addressbook_id: &str,
42 ) -> Result<CollectionMetadata, Error>;
43
44 async fn get_objects(
45 &self,
46 principal: &str,
47 addressbook_id: &str,
48 ) -> Result<Vec<(String, AddressObject)>, Error>;
49 async fn get_object(
50 &self,
51 principal: &str,
52 addressbook_id: &str,
53 object_id: &str,
54 show_deleted: bool,
55 ) -> Result<AddressObject, Error>;
56 async fn put_object(
57 &self,
58 principal: &str,
59 addressbook_id: &str,
60 object_id: &str,
61 object: AddressObject,
62 overwrite: bool,
63 ) -> Result<(), Error>;
64 async fn delete_object(
65 &self,
66 principal: &str,
67 addressbook_id: &str,
68 object_id: &str,
69 use_trashbin: bool,
70 ) -> Result<(), Error>;
71 async fn restore_object(
72 &self,
73 principal: &str,
74 addressbook_id: &str,
75 object_id: &str,
76 ) -> Result<(), Error>;
77
78 async fn import_addressbook(
79 &self,
80 addressbook: Addressbook,
81 objects: Vec<(String, AddressObject)>,
82 merge_existing: bool,
83 ) -> Result<(), Error>;
84}