Files
rustical/crates/store/src/addressbook_store.rs
2026-01-16 15:39:33 +01:00

85 lines
2.4 KiB
Rust

use crate::{CollectionMetadata, Error, addressbook::Addressbook};
use async_trait::async_trait;
use rustical_ical::AddressObject;
#[async_trait]
pub trait AddressbookStore: Send + Sync + 'static {
async fn get_addressbook(
&self,
principal: &str,
id: &str,
show_deleted: bool,
) -> Result<Addressbook, Error>;
async fn get_addressbooks(&self, principal: &str) -> Result<Vec<Addressbook>, Error>;
async fn get_deleted_addressbooks(&self, principal: &str) -> Result<Vec<Addressbook>, Error>;
async fn update_addressbook(
&self,
principal: &str,
id: &str,
addressbook: Addressbook,
) -> Result<(), Error>;
async fn insert_addressbook(&self, addressbook: Addressbook) -> Result<(), Error>;
async fn delete_addressbook(
&self,
principal: &str,
name: &str,
use_trashbin: bool,
) -> Result<(), Error>;
async fn restore_addressbook(&self, principal: &str, name: &str) -> Result<(), Error>;
async fn sync_changes(
&self,
principal: &str,
addressbook_id: &str,
synctoken: i64,
) -> Result<(Vec<(String, AddressObject)>, Vec<String>, i64), Error>;
async fn addressbook_metadata(
&self,
principal: &str,
addressbook_id: &str,
) -> Result<CollectionMetadata, Error>;
async fn get_objects(
&self,
principal: &str,
addressbook_id: &str,
) -> Result<Vec<(String, AddressObject)>, Error>;
async fn get_object(
&self,
principal: &str,
addressbook_id: &str,
object_id: &str,
show_deleted: bool,
) -> Result<AddressObject, Error>;
async fn put_object(
&self,
principal: &str,
addressbook_id: &str,
object_id: &str,
object: AddressObject,
overwrite: bool,
) -> Result<(), Error>;
async fn delete_object(
&self,
principal: &str,
addressbook_id: &str,
object_id: &str,
use_trashbin: bool,
) -> Result<(), Error>;
async fn restore_object(
&self,
principal: &str,
addressbook_id: &str,
object_id: &str,
) -> Result<(), Error>;
async fn import_addressbook(
&self,
addressbook: Addressbook,
objects: Vec<(String, AddressObject)>,
merge_existing: bool,
) -> Result<(), Error>;
}