use std::sync::Arc;
use ibridge_auth::Credentials;
#[cfg(feature = "contacts")]
pub(crate) type Backend = ibridge_contacts::CardDavProvider;
#[cfg(not(feature = "contacts"))]
pub(crate) type Backend = ibridge_server::NoContacts;
#[cfg(feature = "contacts")]
pub(crate) fn backend(credentials: &Credentials) -> anyhow::Result<Arc<Backend>> {
let client = ibridge_dav::DavClient::new(credentials.duplicate())?;
Ok(Arc::new(ibridge_contacts::CardDavProvider::new(client)))
}
#[cfg(not(feature = "contacts"))]
#[expect(
clippy::unnecessary_wraps,
reason = "the contacts build can fail, and both builds share one signature"
)]
pub(crate) fn backend(_credentials: &Credentials) -> anyhow::Result<Arc<Backend>> {
Ok(Arc::new(ibridge_server::NoContacts))
}