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