#![deny(clippy::pedantic)]
use crate::auth::Auth;
use dav::DavError;
use dav::FindCurrentUserPrincipalError;
use dav::RequestError;
use dns::TxtError;
use domain::resolv::lookup::srv::SrvError;
use http::StatusCode;
pub mod auth;
pub mod builder;
mod caldav;
mod carddav;
mod common;
pub mod dav;
pub mod dns;
pub mod names;
pub mod xmlutils;
pub use caldav::CalDavClient;
pub use carddav::CardDavClient;
pub type Property<'ns, 'name> = roxmltree::ExpandedName<'ns, 'name>;
#[derive(thiserror::Error, Debug)]
pub enum InvalidUrl {
#[error("missing scheme")]
MissingScheme,
#[error("scheme is not valid for service type")]
InvalidScheme,
#[error("missing host")]
MissingHost,
#[error("the host is not a valid domain")]
InvalidDomain(domain::base::name::FromStrError),
}
#[derive(thiserror::Error, Debug)]
pub enum BootstrapError {
#[error("the input URL is not valid: {0}")]
InvalidUrl(#[from] InvalidUrl),
#[error("error resolving DNS SRV records")]
DnsError(#[from] SrvError),
#[error("SRV records returned domain/port pair that failed to parse")]
UnusableSrv(http::Error),
#[error("error resolving context path via TXT records")]
TxtError(#[from] TxtError),
#[error(transparent)]
HomeSet(#[from] FindHomeSetError),
#[error("error querying current user principal")]
CurrentPrincipal(#[from] FindCurrentUserPrincipalError),
#[error(transparent)]
DavError(#[from] DavError),
#[error("the service is decidedly not available")]
NotAvailable,
}
#[derive(thiserror::Error, Debug)]
#[error("error finding home set collection")]
pub struct FindHomeSetError(#[source] pub DavError);
#[derive(Debug, PartialEq, Eq)]
pub struct FetchedResourceContent {
pub data: String,
pub etag: String,
}
#[derive(Debug, PartialEq, Eq)]
pub struct FetchedResource {
pub href: String,
pub content: Result<FetchedResourceContent, StatusCode>,
}
#[derive(thiserror::Error, Debug)]
pub enum CheckSupportError {
#[error("the DAV header was missing from the response")]
MissingHeader,
#[error("the requested support is not advertised by the server")]
NotAdvertised,
#[error("the DAV header is not a valid string")]
HeaderNotAscii(#[from] http::header::ToStrError),
#[error("error performing http request")]
Request(#[from] RequestError),
#[error("invalid input URL")]
InvalidInput(#[from] http::Error),
#[error("http request returned {0}")]
BadStatusCode(http::StatusCode),
}
impl From<StatusCode> for CheckSupportError {
fn from(status: StatusCode) -> Self {
CheckSupportError::BadStatusCode(status)
}
}
#[derive(Debug, PartialEq, Eq, Default)]
pub struct ItemDetails {
pub content_type: Option<String>,
pub etag: Option<String>,
pub resource_type: ResourceType,
}
#[derive(Default, Debug, PartialEq, Eq)]
pub struct ResourceType {
pub is_collection: bool,
pub is_calendar: bool,
pub is_address_book: bool,
}