Add ?Sized to CalendarStore generics for dynamic dispatch

This commit is contained in:
Lennart
2023-10-08 14:47:36 +02:00
parent e17e4facd7
commit f6cf5bd645
8 changed files with 21 additions and 18 deletions

View File

@@ -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<C: CalendarStore> {
pub struct CalendarResource<C: CalendarStore + ?Sized> {
pub cal_store: Arc<RwLock<C>>,
pub calendar: Calendar,
pub path: String,
@@ -20,7 +20,7 @@ pub struct CalendarResource<C: CalendarStore> {
}
#[async_trait(?Send)]
impl<C: CalendarStore> Resource for CalendarResource<C> {
impl<C: CalendarStore + ?Sized> Resource for CalendarResource<C> {
type MemberType = Self;
type UriComponents = (String, String); // principal, calendar_id

View File

@@ -9,14 +9,14 @@ use rustical_store::event::Event;
use std::sync::Arc;
use tokio::sync::RwLock;
pub struct EventResource<C: CalendarStore> {
pub struct EventResource<C: CalendarStore + ?Sized> {
pub cal_store: Arc<RwLock<C>>,
pub path: String,
pub event: Event,
}
#[async_trait(?Send)]
impl<C: CalendarStore> Resource for EventResource<C> {
impl<C: CalendarStore + ?Sized> Resource for EventResource<C> {
type UriComponents = (String, String, String); // principal, calendar, event
type MemberType = Self;

View File

@@ -12,7 +12,7 @@ use tokio::sync::RwLock;
use super::calendar::CalendarResource;
pub struct PrincipalCalendarsResource<C: CalendarStore> {
pub struct PrincipalCalendarsResource<C: CalendarStore + ?Sized> {
prefix: String,
principal: String,
path: String,
@@ -20,7 +20,7 @@ pub struct PrincipalCalendarsResource<C: CalendarStore> {
}
#[async_trait(?Send)]
impl<C: CalendarStore> Resource for PrincipalCalendarsResource<C> {
impl<C: CalendarStore + ?Sized> Resource for PrincipalCalendarsResource<C> {
type UriComponents = ();
type MemberType = CalendarResource<C>;