stores: Switch from dyn to impl and implement Sized

This commit is contained in:
Lennart
2025-01-15 17:21:01 +01:00
parent 751c2d1ce7
commit 6d78a3936f
28 changed files with 55 additions and 72 deletions

View File

@@ -41,7 +41,7 @@ struct MkcalendarRequest {
}
#[instrument(parent = root_span.id(), skip(store, root_span))]
pub async fn route_mkcalendar<C: CalendarStore + ?Sized>(
pub async fn route_mkcalendar<C: CalendarStore>(
path: Path<(String, String)>,
body: String,
user: User,

View File

@@ -10,7 +10,7 @@ use tracing::instrument;
use tracing_actix_web::RootSpan;
#[instrument(parent = root_span.id(), skip(store, subscription_store, root_span, req))]
pub async fn route_post<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized>(
pub async fn route_post<C: CalendarStore, S: SubscriptionStore>(
path: Path<(String, String)>,
body: String,
user: User,

View File

@@ -24,7 +24,7 @@ pub(crate) struct CalendarMultigetRequest {
pub(crate) href: Vec<String>,
}
pub async fn get_objects_calendar_multiget<C: CalendarStore + ?Sized>(
pub async fn get_objects_calendar_multiget<C: CalendarStore>(
cal_query: &CalendarMultigetRequest,
path: &str,
principal: &str,
@@ -52,7 +52,7 @@ pub async fn get_objects_calendar_multiget<C: CalendarStore + ?Sized>(
Ok((result, not_found))
}
pub async fn handle_calendar_multiget<C: CalendarStore + ?Sized>(
pub async fn handle_calendar_multiget<C: CalendarStore>(
cal_multiget: CalendarMultigetRequest,
req: HttpRequest,
user: &User,

View File

@@ -175,7 +175,7 @@ pub struct CalendarQueryRequest {
pub(crate) timezone_id: Option<String>,
}
pub async fn get_objects_calendar_query<C: CalendarStore + ?Sized>(
pub async fn get_objects_calendar_query<C: CalendarStore>(
cal_query: &CalendarQueryRequest,
principal: &str,
cal_id: &str,
@@ -188,7 +188,7 @@ pub async fn get_objects_calendar_query<C: CalendarStore + ?Sized>(
Ok(objects)
}
pub async fn handle_calendar_query<C: CalendarStore + ?Sized>(
pub async fn handle_calendar_query<C: CalendarStore>(
cal_query: CalendarQueryRequest,
req: HttpRequest,
user: &User,

View File

@@ -22,7 +22,7 @@ pub(crate) enum ReportRequest {
}
#[instrument(skip(req, cal_store))]
pub async fn route_report_calendar<C: CalendarStore + ?Sized>(
pub async fn route_report_calendar<C: CalendarStore>(
path: Path<(String, String)>,
body: String,
user: User,

View File

@@ -60,7 +60,7 @@ pub(crate) struct SyncCollectionRequest {
pub(crate) limit: Option<u64>,
}
pub async fn handle_sync_collection<C: CalendarStore + ?Sized>(
pub async fn handle_sync_collection<C: CalendarStore>(
sync_collection: SyncCollectionRequest,
req: HttpRequest,
user: &User,

View File

@@ -255,12 +255,12 @@ impl Resource for CalendarResource {
}
}
pub struct CalendarResourceService<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> {
pub struct CalendarResourceService<C: CalendarStore, S: SubscriptionStore> {
cal_store: Arc<C>,
__phantom_sub: PhantomData<S>,
}
impl<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> CalendarResourceService<C, S> {
impl<C: CalendarStore, S: SubscriptionStore> CalendarResourceService<C, S> {
pub fn new(cal_store: Arc<C>) -> Self {
Self {
cal_store,
@@ -270,7 +270,7 @@ impl<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> CalendarResourceS
}
#[async_trait(?Send)]
impl<C: CalendarStore + ?Sized, S: SubscriptionStore + ?Sized> ResourceService
impl<C: CalendarStore, S: SubscriptionStore> ResourceService
for CalendarResourceService<C, S>
{
type MemberType = CalendarObjectResource;

View File

@@ -12,7 +12,7 @@ use tracing_actix_web::RootSpan;
use super::resource::CalendarObjectPathComponents;
#[instrument(parent = root_span.id(), skip(store, root_span))]
pub async fn get_event<C: CalendarStore + ?Sized>(
pub async fn get_event<C: CalendarStore>(
path: Path<CalendarObjectPathComponents>,
store: Data<C>,
user: User,
@@ -42,7 +42,7 @@ pub async fn get_event<C: CalendarStore + ?Sized>(
}
#[instrument(parent = root_span.id(), skip(store, req, root_span))]
pub async fn put_event<C: CalendarStore + ?Sized>(
pub async fn put_event<C: CalendarStore>(
path: Path<CalendarObjectPathComponents>,
store: Data<C>,
body: String,

View File

@@ -14,11 +14,11 @@ use serde::Deserialize;
use std::sync::Arc;
use strum::{EnumDiscriminants, EnumString, IntoStaticStr, VariantNames};
pub struct CalendarObjectResourceService<C: CalendarStore + ?Sized> {
pub struct CalendarObjectResourceService<C: CalendarStore> {
cal_store: Arc<C>,
}
impl<C: CalendarStore + ?Sized> CalendarObjectResourceService<C> {
impl<C: CalendarStore> CalendarObjectResourceService<C> {
pub fn new(cal_store: Arc<C>) -> Self {
Self { cal_store }
}
@@ -110,7 +110,7 @@ impl<'de> Deserialize<'de> for CalendarObjectPathComponents {
}
#[async_trait(?Send)]
impl<C: CalendarStore + ?Sized> ResourceService for CalendarObjectResourceService<C> {
impl<C: CalendarStore> ResourceService for CalendarObjectResourceService<C> {
type PathComponents = CalendarObjectPathComponents;
type Resource = CalendarObjectResource;
type MemberType = CalendarObjectResource;

View File

@@ -67,18 +67,18 @@ impl Resource for CalendarSetResource {
}
}
pub struct CalendarSetResourceService<C: CalendarStore + ?Sized> {
pub struct CalendarSetResourceService<C: CalendarStore> {
cal_store: Arc<C>,
}
impl<C: CalendarStore + ?Sized> CalendarSetResourceService<C> {
impl<C: CalendarStore> CalendarSetResourceService<C> {
pub fn new(cal_store: Arc<C>) -> Self {
Self { cal_store }
}
}
#[async_trait(?Send)]
impl<C: CalendarStore + ?Sized> ResourceService for CalendarSetResourceService<C> {
impl<C: CalendarStore> ResourceService for CalendarSetResourceService<C> {
type PathComponents = (String,);
type MemberType = CalendarResource;
type Resource = CalendarSetResource;

View File

@@ -30,9 +30,9 @@ pub fn configure_well_known(cfg: &mut web::ServiceConfig, caldav_root: String) {
pub fn configure_dav<
AP: AuthenticationProvider,
AS: AddressbookStore + ?Sized,
C: CalendarStore + ?Sized,
S: SubscriptionStore + ?Sized,
AS: AddressbookStore,
C: CalendarStore,
S: SubscriptionStore,
>(
cfg: &mut web::ServiceConfig,
auth_provider: Arc<AP>,

View File

@@ -8,7 +8,7 @@ use rustical_xml::{XmlRootTag, XmlSerialize};
use crate::calendar::resource::CalendarProp;
async fn handle_delete<S: SubscriptionStore + ?Sized>(
async fn handle_delete<S: SubscriptionStore>(
store: Data<S>,
path: Path<String>,
) -> Result<HttpResponse, rustical_store::Error> {
@@ -17,7 +17,7 @@ async fn handle_delete<S: SubscriptionStore + ?Sized>(
Ok(HttpResponse::NoContent().body("Unregistered"))
}
pub fn subscription_resource<S: SubscriptionStore + ?Sized>() -> actix_web::Resource {
pub fn subscription_resource<S: SubscriptionStore>() -> actix_web::Resource {
web::resource("/subscription/{id}")
.name("subscription")
.delete(handle_delete::<S>)