Move ical-related stuff to rustical_ical crate

This commit is contained in:
Lennart
2025-06-03 18:15:26 +02:00
parent 5a6ffd3c19
commit 7f3ce01c2b
35 changed files with 121 additions and 68 deletions

View File

@@ -2,8 +2,8 @@ use crate::Error;
use crate::calendar::prop::SupportedCalendarComponentSet;
use actix_web::HttpResponse;
use actix_web::web::{Data, Path};
use rustical_ical::CalendarObjectType;
use rustical_store::auth::User;
use rustical_store::calendar::CalendarObjectType;
use rustical_store::{Calendar, CalendarStore};
use rustical_xml::{Unparsed, XmlDeserialize, XmlDocument, XmlRootTag};
use tracing::instrument;

View File

@@ -11,7 +11,8 @@ use rustical_dav::{
resource::{PrincipalUri, Resource},
xml::{MultistatusElement, PropfindType, multistatus::ResponseElement},
};
use rustical_store::{CalendarObject, CalendarStore, auth::User};
use rustical_ical::CalendarObject;
use rustical_store::{CalendarStore, auth::User};
use rustical_xml::XmlDeserialize;
#[derive(XmlDeserialize, Clone, Debug, PartialEq)]

View File

@@ -2,8 +2,8 @@ use rustical_dav::{
resource::{PrincipalUri, Resource},
xml::{MultistatusElement, PropfindType},
};
use rustical_ical::UtcDateTime;
use rustical_store::{CalendarObject, CalendarStore, auth::User, calendar_store::CalendarQuery};
use rustical_ical::{CalendarObject, UtcDateTime};
use rustical_store::{CalendarStore, auth::User, calendar_store::CalendarQuery};
use rustical_xml::XmlDeserialize;
use std::ops::Deref;

View File

@@ -1,5 +1,5 @@
use derive_more::derive::{From, Into};
use rustical_store::calendar::CalendarObjectType;
use rustical_ical::CalendarObjectType;
use rustical_xml::{XmlDeserialize, XmlSerialize};
#[derive(Debug, Clone, XmlSerialize, XmlDeserialize, PartialEq, From, Into)]

View File

@@ -4,8 +4,9 @@ use actix_web::HttpResponse;
use actix_web::http::header;
use actix_web::http::header::HeaderValue;
use actix_web::web::{Data, Path};
use rustical_ical::CalendarObject;
use rustical_store::CalendarStore;
use rustical_store::auth::User;
use rustical_store::{CalendarObject, CalendarStore};
use tracing::instrument;
use tracing_actix_web::RootSpan;

View File

@@ -9,7 +9,8 @@ use rustical_dav::{
resource::{PrincipalUri, Resource, ResourceService},
xml::Resourcetype,
};
use rustical_store::{CalendarObject, CalendarStore, auth::User};
use rustical_ical::CalendarObject;
use rustical_store::{CalendarStore, auth::User};
use rustical_xml::{EnumUnitVariants, EnumVariants, XmlDeserialize, XmlSerialize};
use serde::Deserialize;
use std::sync::Arc;

View File

@@ -23,6 +23,9 @@ pub enum Error {
#[error(transparent)]
XmlDecodeError(#[from] rustical_xml::XmlError),
#[error(transparent)]
IcalError(#[from] rustical_ical::Error),
}
impl actix_web::ResponseError for Error {
@@ -30,9 +33,7 @@ impl actix_web::ResponseError for Error {
match self {
Error::StoreError(err) => match err {
rustical_store::Error::NotFound => StatusCode::NOT_FOUND,
rustical_store::Error::InvalidData(_) => StatusCode::BAD_REQUEST,
rustical_store::Error::AlreadyExists => StatusCode::CONFLICT,
rustical_store::Error::ParserError(_) => StatusCode::BAD_REQUEST,
rustical_store::Error::ReadOnly => StatusCode::FORBIDDEN,
_ => StatusCode::INTERNAL_SERVER_ERROR,
},
@@ -42,12 +43,14 @@ impl actix_web::ResponseError for Error {
Error::XmlDecodeError(_) => StatusCode::BAD_REQUEST,
Error::NotImplemented => StatusCode::INTERNAL_SERVER_ERROR,
Error::NotFound => StatusCode::NOT_FOUND,
Error::IcalError(err) => err.status_code(),
}
}
fn error_response(&self) -> actix_web::HttpResponse<actix_web::body::BoxBody> {
error!("Error: {self}");
match self {
Error::DavError(err) => err.error_response(),
Error::IcalError(err) => err.error_response(),
_ => HttpResponse::build(self.status_code()).body(self.to_string()),
}
}