From f6cf5bd6458438e3a9742874827777737bc05276 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:47:36 +0200 Subject: [PATCH] Add ?Sized to CalendarStore generics for dynamic dispatch --- crates/api/src/lib.rs | 7 +++++-- crates/caldav/src/lib.rs | 4 ++-- crates/caldav/src/resources/calendar.rs | 4 ++-- crates/caldav/src/resources/event.rs | 4 ++-- crates/caldav/src/resources/principal.rs | 4 ++-- crates/caldav/src/routes/calendar.rs | 8 ++++---- crates/caldav/src/routes/event.rs | 6 +++--- crates/caldav/src/routes/propfind.rs | 2 +- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 93deecf..d8a506e 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -6,14 +6,17 @@ use actix_web::{ use rustical_store::calendar::CalendarStore; use tokio::sync::RwLock; -pub fn configure_api(cfg: &mut web::ServiceConfig, store: Data>) { +pub fn configure_api( + cfg: &mut web::ServiceConfig, + store: Data>, +) { cfg.app_data(store).route( "/{cid}/events", web::method(Method::GET).to(get_events::), ); } -pub async fn get_events( +pub async fn get_events( store: Data>, path: Path, ) -> impl Responder { diff --git a/crates/caldav/src/lib.rs b/crates/caldav/src/lib.rs index d9f0fd9..a0b879b 100644 --- a/crates/caldav/src/lib.rs +++ b/crates/caldav/src/lib.rs @@ -19,7 +19,7 @@ pub mod proptypes; pub mod resources; pub mod routes; -pub struct CalDavContext { +pub struct CalDavContext { pub prefix: String, pub store: Arc>, } @@ -28,7 +28,7 @@ pub fn configure_well_known(cfg: &mut web::ServiceConfig, caldav_root: String) { cfg.service(web::redirect("/caldav", caldav_root).permanent()); } -pub fn configure_dav( +pub fn configure_dav( cfg: &mut web::ServiceConfig, prefix: String, auth: Arc, diff --git a/crates/caldav/src/resources/calendar.rs b/crates/caldav/src/resources/calendar.rs index 0e1399a..dd74f73 100644 --- a/crates/caldav/src/resources/calendar.rs +++ b/crates/caldav/src/resources/calendar.rs @@ -11,7 +11,7 @@ use tokio::sync::RwLock; use crate::proptypes::{write_href_prop, write_string_prop}; use rustical_dav::{resource::Resource, xml_snippets::write_resourcetype}; -pub struct CalendarResource { +pub struct CalendarResource { pub cal_store: Arc>, pub calendar: Calendar, pub path: String, @@ -20,7 +20,7 @@ pub struct CalendarResource { } #[async_trait(?Send)] -impl Resource for CalendarResource { +impl Resource for CalendarResource { type MemberType = Self; type UriComponents = (String, String); // principal, calendar_id diff --git a/crates/caldav/src/resources/event.rs b/crates/caldav/src/resources/event.rs index 6f27d6a..e77309c 100644 --- a/crates/caldav/src/resources/event.rs +++ b/crates/caldav/src/resources/event.rs @@ -9,14 +9,14 @@ use rustical_store::event::Event; use std::sync::Arc; use tokio::sync::RwLock; -pub struct EventResource { +pub struct EventResource { pub cal_store: Arc>, pub path: String, pub event: Event, } #[async_trait(?Send)] -impl Resource for EventResource { +impl Resource for EventResource { type UriComponents = (String, String, String); // principal, calendar, event type MemberType = Self; diff --git a/crates/caldav/src/resources/principal.rs b/crates/caldav/src/resources/principal.rs index f7571df..5300cae 100644 --- a/crates/caldav/src/resources/principal.rs +++ b/crates/caldav/src/resources/principal.rs @@ -12,7 +12,7 @@ use tokio::sync::RwLock; use super::calendar::CalendarResource; -pub struct PrincipalCalendarsResource { +pub struct PrincipalCalendarsResource { prefix: String, principal: String, path: String, @@ -20,7 +20,7 @@ pub struct PrincipalCalendarsResource { } #[async_trait(?Send)] -impl Resource for PrincipalCalendarsResource { +impl Resource for PrincipalCalendarsResource { type UriComponents = (); type MemberType = CalendarResource; diff --git a/crates/caldav/src/routes/calendar.rs b/crates/caldav/src/routes/calendar.rs index d96c2c4..bfca5d8 100644 --- a/crates/caldav/src/routes/calendar.rs +++ b/crates/caldav/src/routes/calendar.rs @@ -35,7 +35,7 @@ async fn _parse_filter(filter_node: &Node<'_, '_>) { } } -async fn handle_report_calendar_query( +async fn handle_report_calendar_query( query_node: Node<'_, '_>, request: HttpRequest, events: Vec, @@ -76,7 +76,7 @@ async fn handle_report_calendar_query( .body(output)) } -pub async fn route_report_calendar( +pub async fn route_report_calendar( context: Data>, body: String, path: Path<(String, String)>, @@ -101,7 +101,7 @@ pub async fn route_report_calendar( handle_report_calendar_query(query_node, request, events, context.store.clone()).await } -pub async fn handle_mkcol_calendar_set( +pub async fn handle_mkcol_calendar_set( store: &RwLock, prop_node: Node<'_, '_>, cid: String, @@ -139,7 +139,7 @@ pub async fn handle_mkcol_calendar_set( Ok(()) } -pub async fn route_mkcol_calendar( +pub async fn route_mkcol_calendar( path: Path<(String, String)>, body: String, auth: AuthInfoExtractor, diff --git a/crates/caldav/src/routes/event.rs b/crates/caldav/src/routes/event.rs index c0d1b46..9e51bc8 100644 --- a/crates/caldav/src/routes/event.rs +++ b/crates/caldav/src/routes/event.rs @@ -23,7 +23,7 @@ impl ResponseError for Error { } } -pub async fn delete_event( +pub async fn delete_event( context: Data>, path: Path<(String, String, String)>, auth: AuthInfoExtractor, @@ -39,7 +39,7 @@ pub async fn delete_event( Ok(HttpResponse::Ok().body("")) } -pub async fn get_event( +pub async fn get_event( context: Data>, path: Path<(String, String, String)>, _auth: AuthInfoExtractor, @@ -56,7 +56,7 @@ pub async fn get_event( .body(event.get_ics())) } -pub async fn put_event( +pub async fn put_event( context: Data>, path: Path<(String, String, String)>, body: String, diff --git a/crates/caldav/src/routes/propfind.rs b/crates/caldav/src/routes/propfind.rs index d5a0549..7e2c7f2 100644 --- a/crates/caldav/src/routes/propfind.rs +++ b/crates/caldav/src/routes/propfind.rs @@ -66,7 +66,7 @@ fn parse_propfind(body: &str) -> Result, Error> { } } -pub async fn route_propfind( +pub async fn route_propfind( path: Path, body: String, req: HttpRequest,